Skip to content

fix(analyzer): scope duplicate-condition to same If/Else If chain - #437

Merged
Teakowa merged 1 commit into
mainfrom
wright-432-duplicate-condition-chain
Sep 29, 2026
Merged

Teakowa merged 1 commit into
mainfrom
wright-432-duplicate-condition-chain

Conversation

@e54-bot

@e54-bot e54-bot commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #432 — duplicate-condition compared every If/ElseIf/While condition in a rule's flat action list against all earlier ones, so reachable branches (independent If blocks, While conditions, nested/foreign chains) were reported as unreachable with evidence: exact.

  • duplicate_condition_findings now tracks open blocks: If pushes a chain carrying its branch conditions; Else If reports only when it repeats an earlier branch of the innermost chain; While/For push a placeholder so their End stays aligned; disabled actions are unwrapped only to detect block openers.
  • Registry summary/documentation/finding message now describe the actual detection (a repeated Else If within one chain); knownLimits names the nondeterministic-condition (Random *) case per the issue's non-goal.
  • The pre-existing analysis parity test asserted the buggy rule-wide comparison (>= 2 findings including an If/While pair); now asserts exactly the in-chain Else If finding.

Test plan

  • cargo test -p wright-analyzer — 18 pass, incl. 8 new/updated duplicate-condition cases covering every acceptance criterion (independent Ifs, If/While mixes, same-chain repeats, cross-chain isolation, nested chains, loops and disabled blocks inside chain bodies)
  • Ablation verified by independent review: each negative test fails under the old rule-wide comparison
  • Real CLI check: issue reproduction reports 0 findings; If(c)…Else If(c) still reports 1 exact finding on the Else If
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -D warnings, cargo test --workspace --all-targets --all-features (296 pass), git diff --check
  • Independent adversarial review (36-probe harness incl. malformed programmatic programs): SOUND, all findings addressed in a verified follow-up pass

Generated with Devin

Fixes #432

The rule compared every If/ElseIf/While condition in a rule's
flat action list against all earlier ones, flagging reachable branches
(second If blocks, While conditions) as unreachable with evidence: exact.

Track open blocks instead: an If pushes a chain carrying its branch
conditions, an Else If compares only against the innermost chain's earlier
branches, While/For blocks push a placeholder so their End stays aligned,
and a disabled action is unwrapped only to detect a block opener. The
registry summary/documentation/finding message now describe the actual
detection and knownLimits names the nondeterministic-condition case.
@Teakowa
Teakowa merged commit c547756 into main Sep 29, 2026
22 checks passed
@Teakowa
Teakowa deleted the wright-432-duplicate-condition-chain branch September 29, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

duplicate-condition reports independent If blocks as unreachable with exact evidence

2 participants