pmd:LawOfDemeter

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube: Developer Edition Version 7.7 (build 23042), Scanner: mvn sonar:sonar, Plugin: PMD 3.2.1, and any relevant extension: SonarJava 5.13.1 (build 18282))
  • what are you trying to achieve: write high quality software
  • what have you tried so far to achieve this: activate pmd rules in Quality Profile and run SonarQube analysis

Copy/paste from Jira issue written by a developer (I have not verified):

Disable pmd:LawOfDemeter check from SonarQube

There are a ton of false positive reports for that tool. Example is on the screenshot:

Another example for the Java API (Pattern and Matches classes) that it complains about:

After the discussion within the team I haven’t heard of any true positive and helpful report of that rule but I’ve heard about a ton of false positive ones (e.g. from Lera or Yauheni) which were cross-confirmed as such by Yulian. Thus, this check should be disabled.

My reply to the developer:

So what you are saying is, there are too many false positives, when using .equals() and .matches()?
I’d say that’s an excellent case to submit as a bug report to the authors of the plugin. I’m on it!

So here I am…

Hi,

Thanks for the report. Unfortunately, it’s slightly mis-directed. You should file an issue on the PMD project.

 
:smiley:
Ann

1 Like

Done: https://github.com/jensgerdes/sonar-pmd/issues/182