#2160 (comment)
Affects PMD Version:
6.20.0
Rule:
LawOfDemeter
Description:
The rule double counts dot accessor for method that uses angled brackets to specify return type in generic method.
Code Sample demonstrating the issue:
package pmdtests;
import java.util.Arrays;
import java.util.List;
public enum Containment {
;
public static void main(String... args) {
Object obj = "one";
List<Object> objs = Arrays.asList("one", 2, Math.PI, 4);
List<Integer> ints = Arrays.asList(2, 4);
assert objs.contains(obj); // wrong violation: object not created locally
assert objs.containsAll(ints); // wrong violation: object not created locally
assert !ints.contains(obj); // wrong violation: object not created locally
assert !ints.containsAll(objs);// wrong violation: object not created locally
obj = 1;
objs = Arrays.<Object>asList(1, 3); // wrong violation: method chain calls
ints = Arrays.asList(1, 2, 3, 4);
assert ints.contains(obj); // wrong violation: object not created locally
assert ints.containsAll(objs); // wrong violation: object not created locally
}
}
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
#2160 (comment)
Affects PMD Version:
6.20.0
Rule:
LawOfDemeter
Description:
The rule double counts dot accessor for method that uses angled brackets to specify return type in generic method.
Code Sample demonstrating the issue:
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]