Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 476 Bytes

no-gratuitous-expressions.md

File metadata and controls

16 lines (13 loc) · 476 Bytes

no-gratuitous-expressions

If an expression doesn't change the evaluation of the condition, then it is either unnecessary, and condition can be removed, or it makes some code being never executed. In any case, the code should be refactored.

Noncompliant Code Example

function checkState(state: boolean) {
  if (state) {
    console.log("Checking the state");
    if (state) { // Noncompliant, condition is always true
      doSomething();
    }
  }
}