Sdlc/Structural/ArrayLiteralOfLocalsReturn: carve out tuples consumed as arrays; fix message accessor name #1349
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#1349
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The cop
Sdlc/Structural/ArrayLiteralOfLocalsReturnflags a def whose final expression is an array literal of two or more lvars.The prescribed fix (return a
Data.definevalue object) is not always correct.A tuple that the caller consumes as an array breaks when it becomes a value object.
The message also always says
location.<name>accessors (array_literal_of_locals_return/message.rb:27), whatever the object is.Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md).
Observed
Counterexample 1: a pair consumed by
to_h. The cop flagspair, butto_hneeds the array.Counterexample 2:
plugins/os-adr/lib/adr/index.rb:36returns a tuple with an_staleslot. The caller discards that slot, so a value object adds a member nobody reads.Of 20 hits, 13 are test helpers that mirror
Open3.capture3tuples (for exampleplugins/os-me/test/prediction_cli_test.rb:17).Reproduce
n/a: the cop matcher is at
plugins/os-sdlc/lib/os_sdlc/cops/array_literal_of_locals_return.rb:38-51; run the cop on the sample above.Approach
Carve-outs go in the cop matcher, never in a config Exclude list or a test-path exclusion.
Skip a two-element return whose call sites feed
to_h,Hash[], oreach_with_objectpairs.Skip a return with any
_-prefixed element (the caller discards it; drop it instead).Make the message use the real accessor name, not a fixed
location..Required work:
to_hinplugins/os-sdlc/lib/os_sdlc/cops/array_literal_of_locals_return/*.rbAcceptance criteria
[key, value]whose result feedsto_h, when the cop runs, then it reports no offense._-prefixed lvar, when the cop runs, then it reports no offense.location.accessors.Origin
VERDICT: CREATE