mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
29 lines
1.0 KiB
HTML
29 lines
1.0 KiB
HTML
<html>
|
|
<body>
|
|
Reports comparisons where left and right operand represent the identical expression.
|
|
While sometimes comparing an expression with itself could be intended, in most cases, it is an oversight.
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
// Probably left.getLength() == right.getLength() was intended
|
|
boolean result = left.getLength() == left.getLength();
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
To ignore comparisons 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 int 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>
|
|
<p><small>New in 2024.2</small></p>
|
|
</body>
|
|
</html> |