Sdlc/Minitest/PackedArrayAssertion: skip arrays with a splat #1375

Open
opened 2026-10-25 21:23:27 +00:00 by jared · 0 comments
Owner

Problem

Sdlc/Minitest/PackedArrayAssertion fires on arrays with a splat.
A splat in an array literal makes the array one sequence outcome of unknown length; it cannot be split per element.
Shape: a receiverless assert_equal whose first two args are array literals of two or more elements.

Observed

23 hits, for example plugins/os-me/test/active_stretch_test.rb:11.
Sample code that fires:

class PackedTest < Minitest::Test
  def test_prepends_the_header_row
    rows = [%w[b], %w[c]]

    assert_equal [%w[a], %w[b], %w[c]], [%w[a], *rows]
  end

  def test_argv_is_built_in_order
    assert_equal %w[git log --oneline], ["git", *Builder.new.args]
  end
end

Reproduce

Run the cop on the sample above.

Approach

Required work:

  1. Do not fire when either array literal contains a splat element.

Carve-outs go in the cop matcher. Do not add config Exclude lists or test-path exclusions.

Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md)

Origin

  • Trigger: #1325 zero-false-positive audit of the Sdlc cops
  • Improvised this session: none
  • Chain: false positive on valid code ← cop matcher tests a proxy shape, not the real condition ← DESIGN (cop source named in Where:)
  • Root candidate: none found; searched the cop name, its mechanism terms, and false positive
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/packed_array_assertion.rb:14-16
  • Session: eb98cdcd-6783-46a0-b7df-cf18a8fe2a56
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-ticket-1325/eb98cdcd-6783-46a0-b7df-cf18a8fe2a56.jsonl

VERDICT: CREATE

## Problem Sdlc/Minitest/PackedArrayAssertion fires on arrays with a splat. A splat in an array literal makes the array one sequence outcome of unknown length; it cannot be split per element. Shape: a receiverless `assert_equal` whose first two args are array literals of two or more elements. ## Observed 23 hits, for example plugins/os-me/test/active_stretch_test.rb:11. Sample code that fires: ```ruby class PackedTest < Minitest::Test def test_prepends_the_header_row rows = [%w[b], %w[c]] assert_equal [%w[a], %w[b], %w[c]], [%w[a], *rows] end def test_argv_is_built_in_order assert_equal %w[git log --oneline], ["git", *Builder.new.args] end end ``` ## Reproduce Run the cop on the sample above. ## Approach Required work: 1. Do not fire when either array literal contains a `splat` element. Carve-outs go in the cop matcher. Do not add config Exclude lists or test-path exclusions. Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md) ## Origin - Trigger: #1325 zero-false-positive audit of the Sdlc cops - Improvised this session: none - Chain: false positive on valid code ← cop matcher tests a proxy shape, not the real condition ← DESIGN (cop source named in Where:) - Root candidate: none found; searched the cop name, its mechanism terms, and false positive - Where: plugins/os-sdlc/lib/os_sdlc/cops/packed_array_assertion.rb:14-16 - Session: eb98cdcd-6783-46a0-b7df-cf18a8fe2a56 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-ticket-1325/eb98cdcd-6783-46a0-b7df-cf18a8fe2a56.jsonl VERDICT: CREATE
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1375
No description provided.