-
-
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] UnusedPrivateMethod FP with raw type missing from the classpath #5097
Comments
#5083 might be related. Also has use of method reference operator |
I can't reproduce this. Your example does not compile. If I import |
Thanks updated it. I was quickly shrinking my real class into a mock example. Now it does not report a violation :( .... Need to rework my example. A feature fix in itself, compile error should not yield a rule violation should it? |
I think you're right it shouldn't... Tbh since the 7.0.0 release these FPs have pointed out several bugs in the type resolution code and allowed us to improve it, which is why I have delayed fixing the rule... |
@oowekyala i updated the above example. I was trying to not add a dependency but it only fails with that for me anyway |
not familiar with this acronym "FPs". what is that? |
@wac84s FP is short for "false positive" |
I can only reproduce it, when jakarta-validation-api is missing on the auxclasspath. |
Surprisingly this has nothing to do with method references. The following also reproduces the bug: public class UnusedPrivateMethodFalsePositive {
private void doWork(List obj){}
public void execute(List<?> listOfLists) {
doWork(listOfLists);
}
} Importantly |
Following test also gives false positive
|
@sd-ebrukanat Please open a new ticket. This does not appear to be related to the original issue |
Affects PMD Version:
7.3.0
Rule: UnusedPrivateMethod
Description:
private method referenced by method reference operators not getting detected as used
this::mymethod
Code Sample demonstrating the issue:
Expected outcome:
It is not an unused private method
PMD reports a violation at line ..., but that's wrong. That's a false positive.
UnusedPrivateMethodFalsePositive.java:19: UnusedPrivateMethod: Avoid unused private methods such as 'addValidationError(ConstraintViolation)'.
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Maven AND cli both report it
The text was updated successfully, but these errors were encountered: