Files
openide/java/java-impl/resources/inspectionDescriptions/DuplicateCondition.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

29 lines
1006 B
HTML

<html>
<body>
Reports duplicate conditions in <code>&amp;&amp;</code> and <code>||</code> expressions
and branches of <code>if</code> statements.
While sometimes duplicate conditions are intended, in most cases they are the result of an oversight.
<p>Example:</p>
<pre><code>
boolean result = digit1 != digit2 || digit1 != digit2;
</code></pre>
<!-- tooltip end -->
<p>
To ignore conditions that may produce side effects, use the <b>Ignore conditions with side effects</b> option.
Disabling this option may lead to false-positives, for example, when the same method returns different values on subsequent invocations.
</p>
<p>Example:</p>
<pre><code>
native boolean unknownMethod();
...
if (unknownMethod() || unknownMethod()) {
System.out.println("Got it");
}
</code></pre>
<p>Due to possible side effects of <code>unknownMethod()</code> (on the example), the warning will only be
triggered if the <b>Ignore conditions with side effects</b> option is disabled.</p>
</body>
</html>