Conditional expressions which are always true or false can lead to dead code. Such code is always buggy and should never
be used in production.
a = false;
if (a) { // Noncompliant
doSomething(); // never executed
}
if (!a || b) { // Noncompliant; "!a" is always "true", "b" is never evaluated
doSomething();
} else {
doSomethingElse(); // never executed
}
This rule will not raise an issue in either of these cases:
final boolean
final boolean debug = false;
//...
if (debug) {
// Print something
}
true or false.
if (true) {
// do something
}
In these cases it is obvious the code is as intended.