[java] TooFewBranchesForSwitch - also ignore record pattern
This commit is contained in:
parent
d9db4dbcab
commit
13cc79af62
@ -630,7 +630,7 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0.
|
||||
<![CDATA[
|
||||
//(SwitchStatement | SwitchExpression)[ (count(*) - 1) < $minimumNumberCaseForASwitch ]
|
||||
(: exclude pattern matching :)
|
||||
[not(*/SwitchLabel/TypePattern)]
|
||||
[not(*/SwitchLabel/(TypePattern|RecordPattern))]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@ -89,7 +89,7 @@ public class ValidSwitch {
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching</description>
|
||||
<description>[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching #5249</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
sealed interface S permits A {}
|
||||
@ -107,6 +107,22 @@ public class Sample {
|
||||
};
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Record patterns are ignored, too #5249</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
record R(int i) {}
|
||||
|
||||
public class SwitchWithRecordPattern {
|
||||
public void check(R r) {
|
||||
switch(r) {
|
||||
case R(int a) -> System.out.println(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user