forked from phoedos/pmd
[java] TooFewBranchesForSwitch - also ignore record pattern
This commit is contained in:
@@ -630,7 +630,7 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0.
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
//(SwitchStatement | SwitchExpression)[ (count(*) - 1) < $minimumNumberCaseForASwitch ]
|
//(SwitchStatement | SwitchExpression)[ (count(*) - 1) < $minimumNumberCaseForASwitch ]
|
||||||
(: exclude pattern matching :)
|
(: exclude pattern matching :)
|
||||||
[not(*/SwitchLabel/TypePattern)]
|
[not(*/SwitchLabel/(TypePattern|RecordPattern))]
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -89,7 +89,7 @@ public class ValidSwitch {
|
|||||||
</test-code>
|
</test-code>
|
||||||
|
|
||||||
<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>
|
<expected-problems>0</expected-problems>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
sealed interface S permits A {}
|
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>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
</test-data>
|
</test-data>
|
||||||
|
Reference in New Issue
Block a user