PMD – Extensible Multilanguage Static Code Analyzer

PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. It supports Java, JavaScript, Apex and Visualforce, PLSQL, Apache Velocity, XML, XSL.

PMD - Extensible Multilanguage Static Code Analyzer
PMD – Extensible Multilanguage Static Code Analyzer

Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in Java, C, C++, C#, Groovy, PHP, Ruby, Fortran, JavaScript, PLSQL, Apache Velocity, Scala, Objective C, Matlab, Python, Go, Swift and Apex and Visualforce.

The tool is most useful when integrated into your build process. It can then be used as a quality gate, to enforce a coding standard for your codebase. Among other things, the tool can be run:

  • As a Maven goal
  • As an Ant task
  • As a Gradle task
  • From command-line

This utility comes with several command line utilities, like CPD, the rule designer. On Unix, you can run any of them using the script, located inside the bin/ directory of the distribution. The first argument is the name of the utility you want to execute (‘pmd’, ‘designer’, …), e.g. PMD is launched via pmd. The rest of the arguments are specific to the utility used. On Windows, each utility has its own startup script, e.g. pmd.batcpd.bat.

CPD, the copy-paste detector, is also distributed with PMD. 

You can read more and download this tool over here:

Notify of
Inline Feedbacks
View all comments