mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports enum <code>switch</code> statements or expression with <code>default</code> branches which can never be taken,
|
|
because all possible values are covered by a <code>case</code> branch.
|
|
<p>Such elements are redundant, especially for <code>switch</code> expressions, because they don't compile when all
|
|
enum constants are not covered by a <code>case</code> branch.</p>
|
|
<p>
|
|
The language level needs to be configured to 14 to report <code>switch</code> expressions.
|
|
</p>
|
|
<p>The provided quick-fix removes <code>default</code> branches.</p>
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
enum E { A, B }
|
|
int foo(E e) {
|
|
return switch (e) {
|
|
case A -> 1;
|
|
case B -> 2;
|
|
default -> 3;
|
|
};
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
enum E { A, B }
|
|
int foo(E e) {
|
|
return switch (e) {
|
|
case A -> 1;
|
|
case B -> 2;
|
|
};
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>Use the <b>Only report switch expressions</b> option to report only redundant <code>default</code> branches in switch expressions.</p>
|
|
|
|
</body>
|
|
</html> |