Skip to content

[Misc] Fix the SonarQube java:S131 issues of the Checkstyle checks - #1954

Merged
vmassol merged 1 commit into
masterfrom
claude/nifty-bell-6tw81b
Sep 6, 2026
Merged

[Misc] Fix the SonarQube java:S131 issues of the Checkstyle checks#1954
vmassol merged 1 commit into
masterfrom
claude/nifty-bell-6tw81b

Conversation

@claude

@claude claude Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Jira URL

None — this is a [Misc] SonarQube cleanup commit.

Changes

Description

Two java:S131
issues ("Add a default case to this switch"), both in xwiki-commons-tool-verification-resources:

  • SinceFormatCheck#visitToken
  • UnstableAnnotationCheck#visitToken

Both switches dispatch on ast.getType(), handle PACKAGE_DEF (which returns) and the
class/interface/enum tokens (which break), and let every other visited token fall through to the
checking code below. The added default: break; therefore changes nothing at runtime — it just makes
that 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 (a switch where an unhandled value is a real gap) do not occur here:
these are Checkstyle visitToken dispatchers, and the set of tokens they receive is fixed by their
own 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 design
changes, published-API renames or "complete this TODO", not mechanical cleanups.

Screenshots & Video

N/A

Executed Tests

mvn install -Pquality -fae -pl xwiki-commons-tools/xwiki-commons-tool-verification-resources \
  -Dtest=SinceFormatCheckTest,UnstableAnnotationCheckTest -DfailIfNoTests=false

17 tests greenSinceFormatCheckTest 3 and UnstableAnnotationCheckTest 14, i.e. exactly the
suites of the two checks this pull request touches.

-Dtest= is needed, and that is worth flagging because it is pre-existing, not caused by this
change
: built standalone with -pl, this module's surefire discovers no tests at all
(Tests run: 0) even though testCompile compiles all three test classes, so jacoco:check then
fails 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:

module content tests run JaCoCo ratio result
master (8c13f15), no -Dtest 0 0.00 jacoco:check fails
this branch, no -Dtest 0 0.00 jacoco:check fails
this branch, -Dtest=SinceFormatCheckTest,UnstableAnnotationCheckTest 17, all green 0.67 jacoco:check still below the 0.80 floor because the run skips TemporaryFileCheckTest

So 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 the
review. 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

* 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
@claude claude Bot added the llm-agent PR created by an LLM agent label Sep 6, 2026
@claude claude Bot assigned vmassol Sep 6, 2026
@claude claude Bot locked as resolved and limited conversation to collaborators Sep 6, 2026
@vmassol
vmassol merged commit 87b1696 into master Sep 6, 2026
7 checks passed
@vmassol
vmassol deleted the claude/nifty-bell-6tw81b branch September 6, 2026 07:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

llm-agent PR created by an LLM agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant