[Misc] Fix the SonarQube java:S131 issues of the Checkstyle checks - #1954
Merged
Conversation
* Add the missing default case to the token switch of SinceFormatCheck and UnstableAnnotationCheck. Both switches already fall through to the code below for any unhandled token, so the added case is behaviour-neutral. Co-Authored-By: Vincent Massol <vincent@massol.net> Claude-Session: https://claude.ai/code/session_01FTH7nnTgyrquQ4VFuesFYG
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Jira URL
None — this is a
[Misc]SonarQube cleanup commit.Changes
Description
Two
java:S131issues ("Add a default case to this switch"), both in
xwiki-commons-tool-verification-resources:SinceFormatCheck#visitTokenUnstableAnnotationCheck#visitTokenBoth switches dispatch on
ast.getType(), handlePACKAGE_DEF(whichreturns) and theclass/interface/enum tokens (which
break), and let every other visited token fall through to thechecking code below. The added
default: break;therefore changes nothing at runtime — it just makesthat intent explicit, which is what the rule asks for. A comment on the case says so, since "falls
through on purpose" is exactly the thing a future reader would otherwise have to re-derive.
Clarifications
java:S131's other shapes (aswitchwhere an unhandled value is a real gap) do not occur here:these are Checkstyle
visitTokendispatchers, and the set of tokens they receive is fixed by theirown
getDefaultTokens().Nothing else in this repo was shippable this run — the remaining commons SonarCloud pool is
S112/S1133/S1135/S1168/S2065/S2160/S3776/S6355/S9149, all of which are designchanges, published-API renames or "complete this TODO", not mechanical cleanups.
Screenshots & Video
N/A
Executed Tests
17 tests green —
SinceFormatCheckTest3 andUnstableAnnotationCheckTest14, i.e. exactly thesuites of the two checks this pull request touches.
-Dtest=is needed, and that is worth flagging because it is pre-existing, not caused by thischange: built standalone with
-pl, this module's surefire discovers no tests at all(
Tests run: 0) even thoughtestCompilecompiles all three test classes, sojacoco:checkthenfails the module at "instructions covered ratio is 0.00, but expected minimum is 0.80". I ran the
A/B on the same working copy to be sure it is not mine:
master(8c13f15), no-Dtestjacoco:checkfails-Dtestjacoco:checkfails-Dtest=SinceFormatCheckTest,UnstableAnnotationCheckTestjacoco:checkstill below the 0.80 floor because the run skipsTemporaryFileCheckTestSo the module behaves identically before and after the change; I have not tried to fix the discovery
problem here, since repairing unrelated build breakage inside a
[Misc]cleanup would muddle thereview. Happy to file it separately if it is not already known.
Expected merging strategy
Squash and merge; no backport needed.
Related
Part of the same SonarQube sweep as xwiki/xwiki-platform#6325.
Generated by Claude Code