Skip to content

[Misc] Record the deliberate SonarQube name-shadowing false positives in the code - #1974

Open
claude[bot] wants to merge 1 commit into
masterfrom
claude/nifty-bell-ll87u0
Open

claude[bot] wants to merge 1 commit into
masterfrom
claude/nifty-bell-ll87u0

Conversation

@claude

@claude claude Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Jira URL

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

Changes

Description

Records, in the code, the deliberate name shadowing that SonarQube reports as
java:S2176
("Class names should not shadow interfaces or superclasses") and
java:S9149
("Static methods should not hide methods from superclasses").

63 issues over 21 classes, and the diff is insert-only: three lines above a type
declaration, never a change to an existing line. No behaviour can change.

Both rules ask for a rename. In every one of these 21 cases the shared name is the point of the
class — so the remediation the message suggests is either a published-API break or would defeat the
class's only purpose. The resolution the SonarQube guidelines prescribe for that is
@SuppressWarnings("<rule key>") plus a comment saying why, in the code; SonarCloud then closes the
issue at the next analysis because the rule stops being raised. The idiom is already established
here — master carries 26 @SuppressWarnings("java:S…") in xwiki-commons today.

The 63 issues are 4 distinct arguments and 21 classes, so what a reviewer has to check is four
sentences and which group each class belongs to. Note the count is dominated by a single class:
StringTool alone carries 42 of the 63, cleared by one annotation.

A — a deprecated class kept only to preserve the old name (9 issues)

It extends the class that replaced it, under the name it is replacing. Renaming it removes the
backward compatibility it exists for. All nine carry an @deprecated tag naming that replacement.

Class Shadows
o.x.extension.wrap.AbstractWrappingObject o.x.script.wrap.AbstractWrappingObject
o.x.job.internal.AbstractJobStatus o.x.job.AbstractJobStatus
o.x.job.internal.AbstractJob o.x.job.AbstractJob
o.x.velocity.introspection.AbstractChainableUberspector org.apache.velocity.util.introspection.AbstractChainableUberspector
o.x.velocity.introspection.ChainableUberspector org.apache.velocity.util.introspection.ChainableUberspector
o.x.velocity.introspection.DeprecatedCheckUberspector org.apache.velocity.util.introspection.DeprecatedCheckUberspector
o.x.logging.TranslationMarker o.x.logging.marker.TranslationMarker
o.x.extension.repository.xwiki.Resources o.x.repository.Resources
o.x.extension.repository.xwiki.UriBuilder o.x.repository.UriBuilder

B — a drop-in extension of a third-party type (9 issues)

The type adds behaviour to a library type and keeps its name so that it can stand in for it — for
the Velocity tools and the XStream converters, literally, since they are registered in the library's
place. Each one says so in its own Javadoc.

Class Shadows
o.x.text.StringUtils org.apache.commons.lang3.StringUtils
o.x.velocity.tools.CollectionTool org.apache.velocity.tools.generic.CollectionTool
o.x.velocity.tools.ComparisonDateTool org.apache.velocity.tools.generic.ComparisonDateTool
o.x.velocity.tools.EscapeTool org.apache.velocity.tools.generic.EscapeTool
o.x.filter.xml.internal.parameter.CollectionConverter com.thoughtworks.xstream.…CollectionConverter
o.x.filter.xml.internal.parameter.MapConverter com.thoughtworks.xstream.…MapConverter
o.x.groovy.internal.GroovyScriptEngineFactory org.codehaus.groovy.jsr223.GroovyScriptEngineFactory
o.x.logging.Logger org.slf4j.Logger
o.x.xml.EntityResolver org.xml.sax.EntityResolver

o.x.text.StringUtils's Javadoc is explicit about why the name is shared: "the reason we're
extending Commons Lang instead of creating a separate class is because we're using this class as a
Velocity tool and we want to offer a single binding to users"
.

C — a static that deliberately hides the inherited one (43 issues)

Class Static(s) Issues
o.x.velocity.tools.StringTool 42 re-declared StringUtils helpers 42
o.x.logging.internal.tail.XStreamFileLoggerTail exist(Path) 1

StringTool's Javadoc states the purpose outright: "basically org.apache.commons.lang3.StringUtils
but with fewer deprecated methods, to control the deprecation in XWiki and to keep methods available
in Velocity whose recommended alternative isn't available in Velocity"
. Re-declaring the inherited
statics is that mechanism, and the method names are the $stringtool scripting API, so they
cannot be renamed either.

D — a test fixture whose hiding is the thing under test (2 issues)

DefaultVelocityManagerTest.SubTestClass declares overwrittenStaticMethod() and
overwrittenDeprecatedStaticMethod() hiding TestClass's, because the tests below check how the
uberspector resolves exactly that.

Clarifications

  • No @SuppressWarnings was added where I could not state a reason. That is what keeps the rest
    credible; nothing here was suppressed merely to clear a count.
  • The SonarCloud Code Analysis app check may still report a pre-existing finding in one of the 21
    changed files, because the app's project gate counts every issue in a changed file rather than
    the issues the PR's own lines carry. Quality / Analyze — which is this repo's verdict — cannot
    fire on this PR at all: the diff writes no existing line, it only inserts above declarations.

Related

Same sweep, same two rules, in the sibling repos:

Screenshots & Video

N/A

Executed Tests

mvn install -Plegacy,quality -fae -pl <the 12 modules touched>

BUILD SUCCESS, 960 tests green in 5:38 over 12 modules (xwiki-commons-extension-api,
xwiki-commons-filter-xml, xwiki-commons-groovy, xwiki-commons-job-api,
xwiki-commons-job-default, xwiki-commons-legacy-velocity, xwiki-commons-logging-api,
xwiki-commons-logging-common, xwiki-commons-repository-api, xwiki-commons-text,
xwiki-commons-velocity, xwiki-commons-xml). checkstyle:check and revapi:check ran and passed
in all of them.

Expected merging strategy

Squash and merge, master only — no backport needed.


Generated by Claude Code

… in the code

* Suppress the java:S2176 and java:S9149 issues raised on types and static
  methods that carry the name of the type or method they specialise on
  purpose, with a comment stating why in each case.
* 63 SonarQube issues.

Co-Authored-By: Vincent Massol <vincent@massol.net>
Claude-Session: https://claude.ai/code/session_01Y7umCMMQKjGDPL6sojVLdG
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