Files
openide/java/java-impl/resources/inspectionDescriptions/ConfusingElse.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
1.0 KiB
HTML

<html>
<body>
Reports redundant <code>else</code> keywords in <code>if</code>&mdash;<code>else</code> statements and statement chains.
<p>
The <code>else</code> keyword is redundant when all previous branches end with a
<code>return</code>, <code>throw</code>, <code>break</code>, or <code>continue</code> statement. In this case,
the statements from the <code>else</code> branch can be placed after the <code>if</code> statement, and the
<code>else</code> keyword can be removed.
</p>
<p><b>Example:</b></p>
<pre><code>
if (name == null) {
throw new IllegalArgumentException();
} else {
System.out.println(name);
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
if (name == null) {
throw new IllegalArgumentException();
}
System.out.println(name);
</code></pre>
<!-- tooltip end -->
<p>Disable the <b>Report when there are no more statements after the 'if' statement</b> option to ignore cases where the <code>if</code>&mdash;<code>else</code> statement is the last statement in a code block.</p>
</body>
</html>