== Why is this an issue? include::description.adoc[] == How to fix it include::how-to-fix-it.adoc[] === Code examples ==== Noncompliant code example [source,text,diff-id=1,diff-type=noncompliant] ---- if (booleanMethod() == true) { /* ... */ } if (booleanMethod() == false) { /* ... */ } if (booleanMethod() || false) { /* ... */ } doSomething(!false); doSomething(booleanMethod() == true); booleanVariable = booleanMethod() ? true : false; booleanVariable = booleanMethod() ? true : exp; booleanVariable = booleanMethod() ? false : exp; booleanVariable = booleanMethod() ? exp : true; booleanVariable = booleanMethod() ? exp : false; ---- ==== Compliant solution [source,text,diff-id=1,diff-type=compliant] ---- if (booleanMethod()) { /* ... */ } if (!booleanMethod()) { /* ... */ } if (booleanMethod()) { /* ... */ } doSomething(true); doSomething(booleanMethod()); booleanVariable = booleanMethod(); booleanVariable = booleanMethod() || exp; booleanVariable = !booleanMethod() && exp; booleanVariable = !booleanMethod() || exp; booleanVariable = booleanMethod() && exp; ----