Using redundant bit masks in comparisons can be misleading because the bit mask does not alter the result of the comparison. This makes the code
harder to read and understand. It may also suggest incorrect logic or purpose, increasing the risk of errors.
Code examples
Noncompliant code example
let x = 1;
if (x | 2 > 3) { // Noncompliant: Bitwise OR with 1 is redundant in this context
}
Compliant solution
let x = 1;
if (x > 3) { // Compliant: Simplifies the comparison by removing redundant bit operation
}