Skip to content

Files

Latest commit

 

History

History
18 lines (11 loc) · 534 Bytes

BitwiseOperatorInConditional.md

File metadata and controls

18 lines (11 loc) · 534 Bytes

Pattern: Bitwise operator in conditional

Issue: -

Description

Checks for bitwise operations in conditionals. For instance, the condition if (a | b) is almost always a mistake and should be if (a || b). If you need to do a bitwise operation then it is best practice to extract a temp variable.

Example of violations:

if (a | b) { }
if (a & b) { }

Further Reading