mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 08:51:02 +07:00
29 lines
1.0 KiB
HTML
29 lines
1.0 KiB
HTML
<html>
|
|
<body>
|
|
Reports redundant <code>else</code> keywords in <code>if</code>—<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>—<code>else</code> statement is the last statement in a code block.</p>
|
|
|
|
</body>
|
|
</html> |