Skip to content

[Misc] Record the deliberate SonarQube java:S1452 wildcard return types in the code - #1977

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

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

Conversation

@claude

@claude claude Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Jira URL

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

Changes

Description

SonarQube reports java:S1452 "Remove usage of generic wildcard type" on 4 methods of xwiki-commons.

The rule's premise is that a wildcard in a return position is useless, because the caller cannot narrow it, and its remediation is to name an invariant type instead (List<Animal> rather than List<? extends Animal>, or a super/subtype).

That premise does not hold for these sites: each of them returns a type that is generic in a parameter the API deliberately leaves open, so there is no invariant type available to name — the type argument is only known at runtime, or differs per element. This is therefore resolved the way the XWiki code style prescribes for a false positive@SuppressWarnings("java:S1452") plus a // comment stating the reason, in the code — and not by Accepted in SonarCloud, so the reason lives where the next reader is.

File Method(s) Why the wildcard is required
EmbeddableComponentManager createGenericProvider, createJakartaGenericProvider the provider is created for the role type carried by the descriptor, i.e. known only at runtime
DefaultXMLDiff diff(String, String, StringSplitter) the patch element type is decided by the StringSplitter passed in
FilterElementDescriptor getParameters each FilterElementParameterDescriptor in the array has its own parameter type; it is also the declared type of the field and of the constructor argument

The diff is insert-only: 8 added lines, 0 removed, no executable statement touched.

Clarifications

  • The alternative resolution — narrowing the signatures — is a source-incompatible change on published API, which is why it is not proposed here.
  • Related, same sweep: xwiki-platform #6388 (28 issues) and xwiki-rendering #439 (3 issues).

Screenshots & Video

N/A

Executed Tests

cd /home/user/xwiki-commons && mvn install -Plegacy,quality -fae -pl \
  xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-default,\
  xwiki-commons-core/xwiki-commons-diff/xwiki-commons-diff-xml,\
  xwiki-commons-core/xwiki-commons-filter/xwiki-commons-filter-api

BUILD SUCCESS in 3:26 — 194 tests green: component-default 69, diff-xml 79, filter-api 46.

The three repositories were built in one chain, in dependency order commons -> rendering -> platform, so the rendering and platform legs verified against the modified commons jars. revapi:check, checkstyle:check, license:check and jacoco:check ran and passed in all 10 modules.

Expected merging strategy

Squash, no backport needed.


Generated by Claude Code

…es in the code

* SonarQube reports "Remove usage of generic wildcard type" on methods whose return type
  is generic in a parameter that the API deliberately leaves open, so there is no invariant
  type to name and the finding is a false positive.
* Resolve them with @SuppressWarnings("java:S1452") plus the per-site reason, as the XWiki
  code style prescribes for a false positive.

Co-Authored-By: Vincent Massol <vincent@massol.net>
Claude-Session: https://claude.ai/code/session_01CtfNasGyjjcbZDKQTCtTyU
@claude claude Bot added the llm-agent PR created by an LLM agent label Sep 15, 2026
@claude claude Bot assigned vmassol Sep 15, 2026
@claude claude Bot locked as resolved and limited conversation to collaborators Sep 15, 2026
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