Overview
- Bug Type:
- Inverted boolean condition
- Category:
- Functional Logic & Control Flow
Definition
A predicate uses the wrong polarity, flipping the intended branch.
How to fix Inverted boolean condition?
Review truth tables; add explicit tests for both branches; refactor to early-return guards or descriptive helpers; avoid double negatives
Symptoms
Observable signs that may indicate Inverted boolean condition:
- Feature toggles behave opposite to expectation.
- Guard clauses always allow or always block.
- Test for negative case passes while positive fails.
Example Errors:
- AssertionError: expected true to be false
- Unexpected branch executed
- If-condition always true/always false (linter)
