LinthelmIntroductions to linters, static analysis and code-quality tools

Static analysis

What is PMD? An introduction to the cross-language static code analyzer

By the Linthelm editorial team · Published · Updated

PMD is an extensible static code analyzer that works across multiple languages. It reads source code and finds common programming flaws such as unused variables, empty catch blocks and unnecessary object creation. It focuses mainly on Java and Apex, and it is run against a source directory with a ruleset.

Tool
PMD
Made by
PMD
Official site
pmd.github.io
Category
Static analysis

Who makes PMD

PMD is developed under the PMD name, and its source code is hosted on GitHub. Its official website is linked below, and it is the place to start for documentation and downloads.

Some organizations offer services around PMD. Commercial support, including consulting, custom rule development and training, is available from third-party companies rather than from the project itself.

Official website: pmd.github.io

What PMD is for

PMD is for finding flaws in source code without running it. It targets problems that are easy to introduce and easy to overlook in review, such as a variable that is declared but never used, a catch block that silently swallows an exception, or an object created when it does not need to be.

Under the hood, PMD parses source files into abstract syntax trees using JavaCC and Antlr. It then runs rules against those trees to find violations. Because rules operate on the structure of the code rather than on raw text, they can describe patterns precisely.

Who PMD is for

The vendor does not state a target audience, so the following is framing based on what the tool does. PMD suits teams that write Java or Apex, since those are the languages it focuses on. It also suits teams working in the other languages and file formats it supports, including JavaScript, Kotlin, Swift, PL/SQL, HTML, XML and Maven POM files.

Teams that want rules specific to their own codebase can write them. Custom rules can be written in Java or as XPath queries, which makes PMD a candidate for projects with conventions that generic rulesets do not cover.

Notable capabilities

PMD combines a large built-in ruleset with several ways to run and extend it. These are the capabilities documented for the tool.

  • Multi-language analysis: PMD focuses mainly on Java and Apex but supports 16 other languages, including Kotlin, Swift, PL/SQL, HTML, XML and Maven POM files.
  • Built-in rules: PMD ships with more than 400 rules, so it can be used without writing any rules of its own.
  • Custom rules: the ruleset can be extended with rules written in Java or as XPath queries.
  • Copy-paste detection: PMD includes CPD, a copy-paste detector that finds duplicated code in many languages.
  • Command-line use: PMD is run with the check command, pointing at a source directory, a ruleset and an output format.
  • Windows installation: on Windows, PMD can be installed through the Chocolatey package manager.
  • Plugins: PMD has been integrated into various tools as a plugin, including IDE and CI plugins, and an Eclipse plugin is released alongside PMD itself.
  • Scala support note: Scala is supported, but no Scala rules are currently available.

How PMD fits static analysis

Static analysis tools inspect code without executing it, and PMD is a general-purpose example that spans many languages instead of serving a single one. Its rule-based design, with rules run against syntax trees, places it among tools that look for known flaw patterns rather than checking program behavior.

In the wider Linthelm niche of linters, static analysis and code quality, PMD covers two adjacent concerns in one package: rule-based flaw detection and duplicate-code detection through CPD. Because it runs from the command line and has IDE and CI plugins, it can be used at the editor, in a pipeline, or both.

Frequently asked questions

What is PMD used for?

PMD is used to find common programming flaws in source code, such as unused variables, empty catch blocks and unnecessary object creation. It does this by running rules against abstract syntax trees built from the source files.

Which languages does PMD support?

PMD focuses mainly on Java and Apex and supports 16 other languages. Supported languages and formats include JavaScript, Kotlin, Swift, PL/SQL, HTML, XML and Maven POM. Scala is supported, but no Scala rules are currently available.

Can I write custom rules for PMD?

Yes. PMD ships with more than 400 built-in rules and can be extended with custom rules written in Java or as XPath queries.

Does PMD detect duplicated code?

Yes. PMD includes CPD, a copy-paste detector that finds duplicated code in many languages.

How do I run PMD?

PMD is run from the command line with the check command, pointing at a source directory, a ruleset and an output format. It is also available through IDE and CI plugins.

Sources. This introduction is based on the vendor's official pages, checked on 21 November 2026 (Asia/Dhaka):

Linthelm is independent and is not affiliated with PMD. Product names belong to their owners. Features change; confirm details on the official website.