2

Is there any configuration in PMD to prevent it from identifying package statements and import statements as duplicate code? Note that we are running PMD as a Sonar plugin.

Specifically, package declarations in multiple classes within the same package are detected as duplicate code!

Anand
  • 43
  • 5
  • So, in fact, it *is* duplicated code. I think your objection is that there is no way in Java to replace the duplicates with an abstraction. – Ira Baxter Jan 12 '15 at 09:06
  • I expect that PMD must ignore the duplicate package statements as mentioned in http://www.onjava.com/pub/a/onjava/2003/03/12/pmd_cpd.html under section How it works – Anand Jan 13 '15 at 05:29
  • "the tokenizer discards whitespace and some other unneeded tokens like import statements, package statements, and semicolons. This reduces the number of tokens that need to be scanned, and it gets rid of uninteresting duplicate chunks like duplicate sequences of import statements." – Anand Jan 13 '15 at 05:38

0 Answers0