Affects PMD Version: 6.42.0
Rule:
LawOfDemeter https://pmd.github.io/latest/pmd_rules_java_design.html#lawofdemeter
Description: When there is no extra braces, PMD can alert LawOfDemeter correctly, while it fails to alert when adding a pair of braces as shown in the following code.
Code Sample demonstrating the issue:
public class Example {
public void func() {
MyObject myObject = MyObjectProvider.get();
{myObject.func();} //false-negative here
}
}
class MyObject {
public void func(){
// do nothing
}
}
class MyObjectProvider {
public static MyObject get(){
return new MyObject();
}
}
Expected outcome:
PMD should report a violation at line 5, but doesn't. This is a false-negative.
Running PMD through: [CLI]
Affects PMD Version: 6.42.0
Rule:
LawOfDemeter https://pmd.github.io/latest/pmd_rules_java_design.html#lawofdemeter
Description: When there is no extra braces, PMD can alert LawOfDemeter correctly, while it fails to alert when adding a pair of braces as shown in the following code.
Code Sample demonstrating the issue:
Expected outcome:
PMD should report a violation at line 5, but doesn't. This is a false-negative.
Running PMD through: [CLI]