mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
29 lines
1006 B
HTML
29 lines
1006 B
HTML
<html>
|
|
<body>
|
|
Reports duplicate conditions in <code>&&</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> |