[java] TooFewBranchesForSwitch: use new PatternLabel attribute

This commit is contained in:
Andreas Dangel 2024-10-24 11:22:47 +02:00
parent 66d879f707
commit 6f5af6e585
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3

View File

@ -628,9 +628,10 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0.
<property name="xpath">
<value>
<![CDATA[
//(SwitchStatement | SwitchExpression)[ (count(*) - 1) < $minimumNumberCaseForASwitch ]
(: exclude pattern matching :)
[not(*/SwitchLabel/(TypePattern|RecordPattern))]
//(SwitchStatement | SwitchExpression)
[ (count(*) - 1) < $minimumNumberCaseForASwitch ]
(: only consider if no pattern matching is used :)
[*/SwitchLabel[@PatternLabel = false()]]
]]>
</value>
</property>