-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[java] UnusedImports: False positive if wildcard is used and only static methods #2016
Comments
@albfernandez I can't reproduce this, not as a test case nor from CLI with 6.19.0-SNAPSHOT… Any further info you can provide? |
This comment has been minimized.
This comment has been minimized.
Hi I've done some more researching: This doesn't work (prints a violation) this works The same applies to Ant. I need to use auxclasspath for other rules to work |
With type resolution enabled and a correct auxclasspath, we resolve the type of the ASTName node "Object.toString(null)" as "String" - which is the result type of the method call. I think, what we need to do instead is, assign the result type of the method call not to the ASTName, but to the expression:
|
…tic methods Added workaround for wrong typeresolution (method result vs. class of method) Refs pmd#2016
I've tested it and seems to work fine for me. Thanks |
…cations We already resolved the result type of a method invocation, but in some cases, we also need the type of the target reference for static method calls. Reverts the previously introduced fix in UnusedImportsRule. Fixes pmd#2016
This is in the 6.20 milestone, does it mean it's fixed in that version? Because I'm using 6.26 and this issue still occurs. |
@jorn86 Yes, this is what it means. This issue is supposed to be fixed with 6.20.0 already. |
Affects PMD Version:
confirmed from 6.9.0 to 6.17.0 and 6.18
Rule:
UnusedImports
Description:
False positives from UnusedImports in some specific conditions:
Code Sample demonstrating the issue:
Running PMD through: CLI and Ant
Curiously, placing the following test code in UnusedImports.xml works fine:
The text was updated successfully, but these errors were encountered: