Java: Limit the amount of results that MissingEnumInSwitch produces per switch#15961
Merged
igfoo merged 5 commits intogithub:mainfrom Mar 28, 2024
Merged
Java: Limit the amount of results that MissingEnumInSwitch produces per switch#15961igfoo merged 5 commits intogithub:mainfrom
igfoo merged 5 commits intogithub:mainfrom
Conversation
…er switch
The tool status page warns:
An analysis file contained multiple alerts that included more related
locations than our allowed limit of 100.
These alerts correspond to the rule java/missing-case-in-switch.
Only 100 locations were stored for these alerts.
joefarebrother
previously approved these changes
Mar 22, 2024
Contributor
joefarebrother
left a comment
There was a problem hiding this comment.
Looks good 👍
Minor style comment
a2602cc to
b6a1266
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tool status page warns:
Here's one possible fix: This change the query so that we only get a single alert for a switch, but it gives up to 3 cases that are not matched, along with the count of how many more cases there are. What do you think?
Another possibility, that will fix some cases (silencing them completely) but miss others, is C++'s approach of requiring a certain percentage of cases to be covered: https://github.com/github/codeql/blob/main/cpp/ql/src/Likely%20Bugs/Likely%20Typos/MissingEnumCaseInSwitch.ql#L21