Skip to content

Files

Latest commit

 

History

History
34 lines (18 loc) · 898 Bytes

bool.md

File metadata and controls

34 lines (18 loc) · 898 Bytes

Pattern: Redundant or suspicious boolean operator

Issue: -

Description

This rule checks for boolean evaluations that are redundant, suspect or having side effects.

Redundant code may increase maintenance costs by making code more difficult to change and to understand. Remove such code to resolve this issue.

Suspect expressions could mean that evaluation is always true or always false resulting in redundant or unreachable code.

Side effects may alter remaining condition and introduce subtle and hard to detect bugs. Consider moving such code out of boolean expression.

Example of incorrect code:

_ = f == nil || f == nil // redundant or: f == nil

Example of correct code:

_ = f == nil

Further Reading