An extensible cross-language static code analyzer.

PMD is a static code analyzer. It finds common programming flaws, sub-optimal code and code style issues in multiple languages. For example, it can highlight unused variables, empty catch blocks or too complex code, just to name a few.

Programming Languages

Initially PMD started out to be a Java-only code analyzer. But nowadays, it fully supports 7 languages: Java, JavaScript, Salesforce.com Apex, PLSQL, Apache Velocity, XML and XSL. All languages provide many rules, that you can immediately use to check your source code.

Copy-Paste-Detector

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 Salesforce.com Apex.

Usage

PMD has over 50000 monthly downloads and is actively used by many open source and closed source projects. It is integrated into most common build tools like Maven, Gradle and Ant, but it can also be used from the command line. Integrations into CI systems such as Jenkins can provide comparisons between builds to see quality improvements or degradation over time based on the issues found by PMD. When integrated into the build, PMD can serve as a quality gate.

Extensibility

PMD comes out of the box with many rules in the area of code design, optimizations, naming and many more. It provides a flexible infrastructure to customize the existing rules via properties and to define completely new custom rules. The rules can be organized in rulesets, which can be shared within a software project, so that every developer is using the same PMD configuration.

An innovative approach allows to define PMD rules using a single XPath expression, allowing developers to do so without having to write code or deal with PMD internals. PMD ships with a designer tool to help build and test such expressions. More complex rules can be coded in Java using a visitor pattern over the analyzed code.

lightbulb_outline View ideas list

Technologies

  • java
  • javacc
  • xml
  • antlr
  • xpath

Topics

email Mailing list
mail_outline Contact email

PMD 2017 Projects

  • Clément Fournier
    Bringing Object-Oriented Metrics to PMD
    Object-Oriented (OO) metrics synthesize characteristics of OO entities (classes, methods) and of their relations, and if combined efficiently, can...
  • Bendegúz Nagy
    Complete type resolution for Java
    Currently, PMD's support for type resolution with the Java language is limited. This severely restricts the code inspection rules which could be...
close

2017