[Misc] Record the deliberate SonarQube java:S1452 wildcard return types in the code - #1977
Open
claude[bot] wants to merge 1 commit into
Open
claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
…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
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
SonarQube reports
java:S1452"Remove usage of generic wildcard type" on 4 methods ofxwiki-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 thanList<? 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.EmbeddableComponentManagercreateGenericProvider,createJakartaGenericProviderDefaultXMLDiffdiff(String, String, StringSplitter)StringSplitterpassed inFilterElementDescriptorgetParametersFilterElementParameterDescriptorin the array has its own parameter type; it is also the declared type of the field and of the constructor argumentThe diff is insert-only: 8 added lines, 0 removed, no executable statement touched.
Clarifications
Screenshots & Video
N/A
Executed Tests
BUILD SUCCESSin 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:checkandjacoco:checkran and passed in all 10 modules.Expected merging strategy
Squash, no backport needed.
Generated by Claude Code