I use PMD plugin in my Maven project to verify code violations and standards. In Java-8, the PMD complains the below code as Potential violation of Law of Demeter
.
Arrays.asList(1, 2, 3, 4).stream().filter(n -> n % 2 == 0).collect(Collectors.toList());
Also the Optional.ofNullable(value).orElse("another")
, and almost all lambda expressions.
However, I have set the below PMD property in the pom.xml
<targetJdk>1.8</targetJdk>
<rulesets>
<ruleset>/category/java/bestpractices.xml</ruleset>
<ruleset>/category/java/design.xml</ruleset>
<!-- <ruleset>/category/java/codestyle.xml</ruleset> -->
<ruleset>/category/java/errorprone.xml</ruleset>
<ruleset>/category/java/security.xml</ruleset>
<ruleset>/category/java/multithreading.xml</ruleset>
<ruleset>/category/java/performance.xml</ruleset>
</rulesets>
Did I miss anything in configuration? Any fixes you can propose?