Sdlc/Structural/DiscardedErrorCode: carve out predicate conditions and per-branch exception classes; state the fix #1353
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#1353
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/DiscardedErrorCodeflags a two-argumentraiseinside anif/casewhose condition namescode,error_code,status, orstatus_code.It flags cases where no code exists to carry, and its message names no correction.
Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md).
Observed
Counterexample 1: a boolean predicate has no code to carry. The only hit in plugins/ is
plugins/os-adr/lib/adr/judge/claude_command.rb:32(unless status.success?).Counterexample 2: per-branch exception classes already encode the code.
The message (
discarded_error_code.rb:15) names no correction.Reproduce
n/a: matcher is
plugins/os-sdlc/lib/os_sdlc/cops/structural/discarded_error_code/raise_site.rb:13-40; 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 when the discriminator appears only as the receiver of a
?predicate.Skip
caseraises whose exception class differs perwhen.The message names the correction, for example
raise Error.new(msg, code: code).Required work:
code:inplugins/os-sdlc/lib/os_sdlc/cops/structural/discarded_error_code.rbAcceptance criteria
unless status.success?guarding a two-argument raise, when the cop runs, then it reports no offense.case codewhosewhenbranches raise different classes, when the cop runs, then it reports no offense.if status.code == 1(orif status.failed? || code == 5) guarding a two-argument raise, when the cop runs, then it still reports the offense: the discriminator is read as a value, not only as the receiver of a?predicate.case codewhosewhenbranches all raise the same class, when the cop runs, then it still reports each raise.Owner sketch
DiscardedErrorCode::RaiseSite(plugins/os-sdlc/lib/os_sdlc/cops/structural/discarded_error_code/raise_site.rb) owns the decision "does this raise discard the discriminator". It gains both carve-outs: a condition whose discriminator name appears only as the receiver of a?predicate yields no discriminator; acaseancestor whosewhenbodies raise more than one distinct class is not a discarding site.DiscardedErrorCode(discarded_error_code.rb) ownsMESSAGE; it names the correctionraise Error.new(msg, code: code).plugins/os-sdlc/lint-lessons/sdlc-structural-discarded-error-code.yml: update the signal to state both carve-outs.Origin
VERDICT: CREATE
Work started on branch ticket-1353 (os-sdlc implement, AFK unit).
Resolution
Done: Sdlc/Structural/DiscardedErrorCode no longer reports a two-argument raise whose discriminator appears only as the receiver of a ? predicate (unless status.success?), or a raise inside a case whose when branches raise different classes. The message now names the correction: raise Error.new(msg, code: code). Lesson YAML signal states both carve-outs. Pipeline implementation 204, commit
79736144, merged to main and pushed.Evidence: Tests: 5 new in plugins/os-sdlc/tests/cops/discarded_error_code_test.rb, 2 suppression + 3 must-fire (if status.code == 1; if status.failed? || code == 5; case code with the same class in each when). Full os-sdlc suite 2855 runs, 0 failures, 33.9s. Probe: cop over plugins/ 0 offenses before and after (the old FP file claude_command.rb was removed by #1437); scratch true case still 2 offenses; real site ~/dev/ruby-gems/shortpixel/lib/shortpixel/resource.rb still 25 offenses. #1451 (widening) is now unblocked except for Jared's ruling.
Follow-ups: #1452 (required-work check with a glob that matches no file loops programmer-repair; seen in this run). Known miss, not filed: a case where some when branches share a class and one differs is skipped as a whole.