Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Latest commit

 

History

History
36 lines (28 loc) · 760 Bytes

no-gratuitous-expressions.md

File metadata and controls

36 lines (28 loc) · 760 Bytes

no-gratuitous-expressions

If a boolean expression doesn’t change the evaluation of the condition, then it is entirely unnecessary, and can be removed. If it is gratuitous because it does not match the programmer’s intent, then it’s a bug and the expression should be fixed.

Noncompliant Code Example

if (a) {
  if (a) { // Noncompliant
    doSomething();
  }
}

Compliant Solution

if (a) {
  if (b) {
    doSomething();
  }
}

// or
if (a) {
  doSomething();
}

See