30 lines
619 B
Plaintext
30 lines
619 B
Plaintext
Boolean literals should be avoided in comparison expressions ``++==++`` and ``++!=++`` to improve code readability.
|
|
|
|
This rule also reports on redundant boolean operations.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
let someValue = "0";
|
|
// ...
|
|
|
|
if (someValue == true) { /* ... */ }
|
|
if (someBooleanValue != true) { /* ... */ }
|
|
doSomething(!false);
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
if (someValue && someValue != "0") { /* ... */ }
|
|
if (!someBooleanValue) { /* ... */ }
|
|
doSomething(true);
|
|
----
|
|
|
|
ifdef::rspecator-view[]
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::rspecator-view[]
|