Affects PMD Version:
6.22.0
Rule:
https://pmd.github.io/latest/pmd_rules_java_codestyle.html#usediamondoperator
Description:
Code Sample demonstrating the issue:
@FunctionalInterface
public interface LambdaKey<T> {
String key(T value);
}
--- different file
public class LambdaKeyConverter<T> {
public LambdaKeyConverter(final LambdaKey<T> lambdaKey) {
}
}
--- different file
import java.util.List;
public class SomeClass {
private final LambdaKeyConverter converter = new LambdaKeyConverter<List>(list -> String.valueOf(list.size()));
}
A SSCCE is provided at https://gitlab.com/krichter-sscce/pmd-diamond-operator-lambda-false-positive with CI output at https://gitlab.com/krichter-sscce/pmd-diamond-operator-lambda-false-positive/-/jobs/489958762
Expected outcome:
This is a false-positive as <List> is necessary in order to allow list.size() to compile.
Running PMD through: Maven
Affects PMD Version:
6.22.0
Rule:
https://pmd.github.io/latest/pmd_rules_java_codestyle.html#usediamondoperator
Description:
Code Sample demonstrating the issue:
A SSCCE is provided at https://gitlab.com/krichter-sscce/pmd-diamond-operator-lambda-false-positive with CI output at https://gitlab.com/krichter-sscce/pmd-diamond-operator-lambda-false-positive/-/jobs/489958762
Expected outcome:
This is a false-positive as
<List>is necessary in order to allowlist.size()to compile.Running PMD through: Maven