Skip to content

[Misc] Use instanceof pattern matching instead of explicit casts (SonarQube java:S6201) - #1858

Merged
vmassol merged 1 commit into
masterfrom
claude/nifty-bell-lm4cfw
Jul 30, 2026
Merged

[Misc] Use instanceof pattern matching instead of explicit casts (SonarQube java:S6201)#1858
vmassol merged 1 commit into
masterfrom
claude/nifty-bell-lm4cfw

Conversation

@claude

@claude claude Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Mechanical SonarCloud cleanup: converts every java:S6201 ("Replace this instanceof check and cast
with 'instanceof Foo foo'") issue open in five commons modules to Java 16+ instanceof pattern
matching — 53 issues, no behaviour change.

Modules: xwiki-commons-component-default, xwiki-commons-filter-api, xwiki-commons-job-api,
xwiki-commons-logging-api, xwiki-commons-properties.

The transform is either "bind the existing explicit local into the pattern and delete its
declaration" or "bind a new pattern variable and drop the inline casts inside its flow scope". Casts
to a different type, or outside the pattern variable's scope, were left untouched.

SonarCloud: https://sonarcloud.io/project/issues?id=org.xwiki.commons%3Axwiki-commons&rules=java%3AS6201

Verified with mvn install -Plegacy,quality on the five modules (tests, Checkstyle, Revapi and
JaCoCo all green).

Related (same sweep, one PR per repo):


Generated by Claude Code

…arQube java:S6201)

* Convert 53 instanceof-and-cast sites in xwiki-commons-component-default,
  xwiki-commons-filter-api, xwiki-commons-job-api, xwiki-commons-logging-api and
  xwiki-commons-properties to Java 16+ instanceof pattern matching.

Co-Authored-By: Vincent Massol <vincent@massol.net>
@claude claude Bot added the llm-agent PR created by an LLM agent label Jul 30, 2026
@claude claude Bot assigned vmassol Jul 30, 2026
@claude claude Bot locked as resolved and limited conversation to collaborators Jul 30, 2026
@vmassol
vmassol merged commit 8e8ddbf into master Jul 30, 2026
3 checks passed
@vmassol
vmassol deleted the claude/nifty-bell-lm4cfw branch July 30, 2026 07:43
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