PMD is an extensible multilanguage static code analyzer. It finds common programming flaws like unused variables,empty catch blocks, unnecessary object creation, and so forth. It’s mainly concerned withJava andApex, butsupports 16 other languages. It comes with400+ built-in rules. It can beextended with custom rules. It uses JavaCC and Antlr to parse source files into abstract syntax trees(AST) and runs rules against them to find violations. Rules can be written in Java or using a XPath query.
Currently, PMD supports Java, JavaScript, Salesforce.com Apex and Visualforce,Kotlin, Swift, Modelica, PL/SQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML and XSL.Scala is supported, but there are currently no Scala rules available.
Additionally, it includesCPD, the copy-paste-detector. CPD finds duplicated code inCoco, C/C++, C#, CSS, Dart, Fortran, Gherkin, Go, Groovy, HTML, Java, JavaScript, JSP, Julia, Kotlin,Lua, Matlab, Modelica, Objective-C, Perl, PHP, PL/SQL, Python, Ruby, Rust, Salesforce.com Apex andVisualforce, Scala, Swift, T-SQL, Typescript, Apache Velocity, WSDL, XML and XSL.
PMD features manybuilt-in checks (in PMD lingo,rules), which are documentedfor each language in ourRule references. Wealso support an extensive API towrite your own rules,which you can do either in Java or as a self-contained XPath query.
PMD is most useful whenintegrated into your build process. It can then beused as a quality gate, to enforce a coding standard for your codebase. Among otherthings, PMD can be run:
CPD, thecopy-paste detector, is also distributed with PMD. You can use itin a variety of ways, which aredocumented here.
The latest release of PMD can be downloaded from ourGithub releases page.
The Logo is available from theLogo Project Page.
The rest of this page exposes the contents of the documentation site thematically,which you can further scope down using the blue filter buttons. To navigate the site,you may also use the search bar in the top right, or the sidebar on the left.
This project follows theall-contributors specification.Contributions of any kind welcome!
Seecredits for the complete list.
These pages summarize the gist of PMD usage to get you started quickly.
Pick your language to find out about the rule it supports.
These pages document the process of writing and testing custom rules and metrics for PMD.
Learn how to build effective and versatile rulesets.
If you'd like to help us build PMD, these topics may interest you. See you around!
These pages describe solutions that integrate PMD within your build process.