Affects PMD Version: 7.10.0
Rule: UnusedPrivateMethod
Description:
When using Lombok val, the type of the local variable is lombok.val
instead of the inferred correct type.
When such a variable is used in a method call, we don't find the correct method declaration due to the different types and report the called method as unused.
Workaround: Don't use val
, use final var
instead. Note: lombok val is a final local variable, while Java's var, is a non-final local variable.
Code Sample demonstrating the issue:
package sample; import lombok.val; class Foo { public void method() { val test = "a"; privateMethod(test); } private void privateMethod(String a) { System.out.println(a); } }
Complete reproducer project: issue-5369-unusedprivatemethod.zip
Expected outcome:
PMD reports a violation at line 12, but that's wrong. That's a false positive.
Running PMD through: Maven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4