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