You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] NonExhaustiveSwitch fails on exhaustive switch with sealed class #5793
Expected outcome:
[WARNING] PMD Failure: BugSealedClassTest:19 Rule:NonExhaustiveSwitch Priority:3 Switch statements or expressions should be exhaustive, add a default case (or missing enum branches).
PMD reports a violation at line 19, but that's wrong. That's a false positive.
changed the title [-]ExhaustiveSwitchHasDefault fails on exhaustive swicth with sealed class[/-][+][java] ExhaustiveSwitchHasDefault fails on exhaustive switch with sealed class[/+]on Jun 6, 2025
changed the title [-][java] ExhaustiveSwitchHasDefault fails on exhaustive switch with sealed class[/-][+][java] NonExhaustiveSwitch fails on exhaustive switch with sealed class[/+]on Jun 6, 2025
Thanks for reporting.
For "NonExhaustiveSwitch" we already try to exclude switch statements, which contain pattern matching - but we didn't consider the "case null" case...
The older issue is this one: #4813
Activity
[-]ExhaustiveSwitchHasDefault fails on exhaustive swicth with sealed class[/-][+][java] ExhaustiveSwitchHasDefault fails on exhaustive switch with sealed class[/+][-][java] ExhaustiveSwitchHasDefault fails on exhaustive switch with sealed class[/-][+][java] NonExhaustiveSwitch fails on exhaustive switch with sealed class[/+]adangel commentedon Jun 6, 2025
Thanks for reporting.
For "NonExhaustiveSwitch" we already try to exclude switch statements, which contain pattern matching - but we didn't consider the "case null" case...
The older issue is this one: #4813
Fix pmd#5793: [java] NonExhaustiveSwitch should ignore "case null"
Fix #5793: [java] NonExhaustiveSwitch should ignore "case null" (#5800)