-
Notifications
You must be signed in to change notification settings - Fork 0
Labels
enhancementNew feature or requestNew feature or request
Description
Description
When a condition is duplicated in an else if chain, the later branch is unreachable because the else path already implies the previous condition is false. The analyzer should flag these cases to surface dead code and logic errors.
Add a dedicated analysis pass that:
- Finds conditional branches whose condition duplicates a dominating
ifcondition along the false successor path. - Canonicalizes operands (including commutative comparisons) to avoid missing equivalent conditions.
- Skips cases where intervening writes can change the compared values.
- Uses debug info plus a light source check to confirm the control-flow is truly an
else ifchain.
Emit a DuplicateIfCondition warning with precise source location and a short explanation.
Acceptance Criteria
- A new warning
DuplicateIfConditionis emitted for duplicate conditions inelse ifchains. - Equivalent conditions with commuted operands are detected.
- Distinct conditions and separate
ifstatements are not flagged. - Tests cover positive and negative cases.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request