mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
34 lines
1.0 KiB
HTML
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> |