SONARJAVA-5936 : S1452 Remove FPs for wildcards in nested types#5391
Open
SONARJAVA-5936 : S1452 Remove FPs for wildcards in nested types#5391
Conversation
BartLucien
reviewed
Jan 22, 2026
Contributor
BartLucien
left a comment
There was a problem hiding this comment.
I just have a small comment concerning the tests.
While it may create some false negatives, as having wildcard in nested types won't be detected. I think it is better than having a issue raised that breaks the compilation if it is fixed. What do you think?
I do not approve as I think there should be a more authoritative answer to your concern.
...hecks-test-sources/default/src/main/java/checks/WildCardReturnParameterNestedTypeSample.java
Show resolved
Hide resolved
08adf1a to
c96bddd
Compare
|
...checks-test-sources/default/src/main/java/checks/WildCardReturnParameterNestedTypeCheck.java
Outdated
Show resolved
Hide resolved
...checks-test-sources/default/src/main/java/checks/WildCardReturnParameterNestedTypeCheck.java
Outdated
Show resolved
Hide resolved
72695bf to
a896a4b
Compare
25d2bc4 to
0434398
Compare
|
tomasz-tylenda-sonarsource
approved these changes
Feb 4, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.





This PR aims to remove False Positives (FPs) in code examples involving nested generics, such as:
The Proposed Solution:
The fix stops checking wildcards after depth 1 nested types (i.e., removing the recursive check).
Reviewer Note:
Please pay attention to this change in behavior; while it resolves the FPs, it means the rule will no longer flag potential issues in deeper nested structures. I would like your feedback on whether this trade-off makes sense or if we should consider a more surgical approach to the recursion.