GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||
GeezerVison is showing github.com — [java] Fix #6984: ExhaustiveSwitchHasDefault: list missing cases in the violation by AzazelSensei · Pull Request #6996 · pmd/pmd Conversation
Contributor
Describe the PRExhaustiveSwitchHasDefault used to say the switch was exhaustive even without default. That read like a false positive when a constant (NEW in the issue) only lived in The message is now: Replace default case with explicit cases (NEW) to make sure compiler keeps checking that all cases are present. If nothing is missing, the parenthetical is dropped. More than three names get truncated with Related issuesReady?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Compared to main: (comment created at 2026-10-18 15:30:01+00:00 for b787944) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
By checking the regressionreport it's obvious there are multiple cases that need different messages:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The old message said the switch was already exhaustive. That hid the constants still only handled by default. UncleOwen asked for the missing names, truncated after three. Fixes pmd#6984
046992b to
8846018
Compare
|
Rebased onto main. Arrow switch expressions with no missing constants now say to remove the default. Colon-style branches and switch statements still use the original message — those look like a separate call on whether to report them. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
The helper was package-private for tests; cover enum, sealed, fully covered, and non-class selectors.
|
@zbynek What do you think about this one? I think the message for the other cases should be changed as well. Maybe "... so that NonExhaustiveSwitch can check them" for the cases where the compiler doesn't check them? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| <expected-problems>1</expected-problems> | ||
| <expected-linenumbers>6</expected-linenumbers> | ||
| <expected-messages> | ||
| <message>Replace default case with explicit cases to make sure compiler keeps checking that all cases are present.</message> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For this one the suggestion should be also "remove" rather than "replace" and it should not mention compiler checks.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll replace the message with "Remove default case and use the rule NonExhaustiveSwitch to make sure the switch stays exhaustive."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The rule NonExhaustiveSwitch should be used to make sure the switch stays exhaustive.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I'll update the message (remove the compiler check hint for switch statements) and merge, if it looks ok.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| <expected-problems>1</expected-problems> | ||
| <expected-linenumbers>6</expected-linenumbers> | ||
| <expected-messages> | ||
| <message>Replace default case with explicit cases to make sure compiler keeps checking that all cases are present.</message> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll replace the message with "Remove default case and use the rule NonExhaustiveSwitch to make sure the switch stays exhaustive."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[java] ExhaustiveSwitchHasDefault: Improve violation messages to list missing cases
There was an error while loading. Please reload this page.