Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 546 Bytes

no-redundant-boolean.md

File metadata and controls

23 lines (18 loc) · 546 Bytes

no-redundant-boolean

Redundant Boolean literals should be removed from expressions to improve readability.

Noncompliant Code Example

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

Compliant Solution

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