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

34 lines
1.0 KiB
HTML

<html>
<body>
Reports <code>if</code> statements
that contain <code>else</code> branches and whose conditions are negated.
<p>Flipping the order of the <code>if</code> and <code>else</code>
branches usually increases the clarity of such statements.</p>
<p>There is a fix that inverts the current <code>if</code> statement.</p>
<p>Example:</p>
<pre><code>
void m(Object o1, Object o2) {
if (o1 != o2) {
System.out.println(1);
}
else {
System.out.println(2);
}
}
</code></pre>
<p>After applying the quick-fix:</p>
<pre><code>
void m(Object o1, Object o2) {
if (o1 == o2) {
System.out.println(2);
} else {
System.out.println(1);
}
}
</code></pre>
<!-- tooltip end -->
<p>Use the <b>Ignore '!= null' comparisons</b> option to ignore comparisons of the <code>!= null</code> form.</p>
<p>Use the <b>Ignore '!= 0' comparisons</b> option to ignore comparisons of the <code>!= 0</code> form.</p>
</body>
</html>