if statements with conditions that are always false have the effect of making blocks of code non-functional. if
statements with conditions that are always true are completely redundant, and make the code less readable.
There are three possible causes for the presence of such code:
In any of these cases, unconditional if statements should be removed.
if (true) { // Noncompliant
doSomething();
}
...
if (false) { // Noncompliant
doSomethingElse();
}
if (!options || options === true) { doThirdThing(); } // Noncompliant; always true
doSomething(); doThirdThing();
This rule is deprecated; use {rule:javascript:S2583} instead.