rspec/rules/S6646/java/how-to-fix-it.adoc

10 lines
534 B
Plaintext

== How to fix it
Gratuitous boolean expressions are suspicious and should be carefully removed from the code.
First, the boolean expression in question should be closely inspected for logical errors.
If a mistake was made, it can be corrected so the condition is no longer gratuitous.
If it becomes apparent that the condition is actually unnecessary, it can be removed. The associated control flow construct
(e.g., the `if`-statement containing the condition) will be adapted or even removed, leaving only the necessary branches.