44 lines
980 B
Plaintext
44 lines
980 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
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;
|
||
|
|
||
|
for (var x = 0; true; x++)
|
||
|
{
|
||
|
...
|
||
|
}
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
if (booleanMethod()) { /* ... */ }
|
||
|
if (!booleanMethod()) { /* ... */ }
|
||
|
if (booleanMethod()) { /* ... */ }
|
||
|
doSomething(true);
|
||
|
doSomething(booleanMethod());
|
||
|
|
||
|
booleanVariable = booleanMethod();
|
||
|
booleanVariable = booleanMethod() || exp;
|
||
|
booleanVariable = !booleanMethod() && exp;
|
||
|
booleanVariable = !booleanMethod() || exp;
|
||
|
booleanVariable = booleanMethod() && exp;
|
||
|
|
||
|
for (var x = 0; ; x++)
|
||
|
{
|
||
|
...
|
||
|
}
|
||
|
----
|