Boolean expressions should be as compact as possible

  • squid : S1125

Boolean expressions should be as compact as possible to improve readability. Useless operators should be removed.

Noncompliant Code Example

if (booleanVariable == true) { /* ... */ }
if (booleanVariable != true) { /* ... */ }
if (booleanVariable || false) { /* ... */ }
doSomething(!false);

Compliant Solution

if (booleanVariable) { /* ... */ }
if (!booleanVariable) { /* ... */ }
if (booleanVariable) { /* ... */ }
doSomething(true);
Close