1

A popular attempt to bypass Salesforce Apex code coverage rules are code busters where one statement is used in thousands of repeating lines.

We have found variations like i=1; or a++; or a=b; with endless variations for the variable name. All have in common that two (or more) consecutive lines (excluding empty or comments) are identical.

How can I discover those in PMD?

Linus Fernandes
  • 498
  • 5
  • 30
stwissel
  • 20,110
  • 6
  • 54
  • 101

1 Answers1

1

This sound more like a use case for the copy paste detector. This is a separate tool also available from PMD: https://pmd.github.io/pmd-6.12.0/pmd_userdocs_cpd.html

However, CPD is focused on finding duplicated code between different files, whereas you seem to be looking for duplicated code within one file.

adangel
  • 1,816
  • 14
  • 17
  • I’m specifically searching for consecutive identical lines. I’m aware of CPD - we had lots of fun with it (and some red faces). Doesn’t really work for that use case – stwissel Mar 09 '19 at 17:19