PMD

PMD

An extensible cross-language static code analyzer.



Latest Version: 7.0.0-rc4 (30-September-2023)
Release Notes | Source


QuickStart


See also Getting Started
$ cd $HOME
$ wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F7.0.0-rc4/pmd-dist-7.0.0-rc4-bin.zip
$ unzip pmd-dist-7.0.0-rc4-bin.zip
$ alias pmd="$HOME/pmd-bin-7.0.0-rc4/bin/pmd"
$ pmd check -d /usr/src -R rulesets/java/quickstart.xml -f text
$ cd $HOME
$ curl -OL https://github.com/pmd/pmd/releases/download/pmd_releases%2F7.0.0-rc4/pmd-dist-7.0.0-rc4-bin.zip
$ unzip pmd-dist-7.0.0-rc4-bin.zip
$ alias pmd="$HOME/pmd-bin-7.0.0-rc4/bin/pmd"
$ pmd check -d /usr/src -R rulesets/java/quickstart.xml -f text
  1. Download pmd-dist-7.0.0-rc4-bin.zip
  2. Extract the zip-archive, e.g. to C:\pmd-bin-7.0.0-rc4
  3. Add folder C:\pmd-bin-7.0.0-rc4\bin to PATH, either
    1. Permanently: Using System Properties dialog > Environment variables > Append to PATH variable
    2. Temporarily, at command line: SET PATH=C:\pmd-bin-7.0.0-rc4\bin;%PATH%
  4. Execute at command line: pmd.bat check -d c:\src -R rulesets/java/quickstart.xml -f text
  1. Install Chocolatey, if you don't already have it!
  2. Install package PMD: choco install -y pmd
  3. Run from the command-line! pmd check -d c:\src -R rulesets/java/quickstart.xml -f text
Checkout the existing rules for Java.


About PMD


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, Salesforce.com Apex and Visualforce, PLSQL, Apache Velocity, XML, XSL.

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 and Visualforce.




Support


Need help?

Get Involved

See How to contribute to PMD and How to build PMD.

Our license: BSD-style.

Source Code: Check it out on github