PMD

PMD

Extensible cross-language static source code analyser

Description

The tiring part of code review is rarely the design discussion. It is pointing out, again, that a variable is unused, that an exception is being swallowed, that these three blocks are nearly identical. A machine reads that faster than a person does.

PMD does exactly that job. It parses source into a syntax tree and matches rules against it, surfacing empty catch blocks, unused private methods, conditions that can only be true, and branches that have grown out of hand. The bundled CPD finds copy-pasted code across files, which tends to turn up startling numbers in older projects. It covers Java, JavaScript, Apex, C#, Kotlin, Swift and a dozen more, rules can be written in XPath, and it drops into CI to run on every commit.

Features



Many languages, one engine: Java, Kotlin, Swift, C#, JavaScript, Apex, PL/SQL and XML all share the same analyser and report formats.

CPD duplicate detection: Token-based comparison catches copy-paste that has been renamed or reordered, across files and languages.

Custom rules: Hundreds of built-in rules to pick from, plus XPath expressions or Java classes for your own team conventions.

Report formats that fit: Text, HTML, XML, SARIF and CSV, ready for GitHub code scanning or SonarQube.

Build integration: Maven, Gradle and Ant plugins, or a plain CLI in CI that fails the pipeline past a threshold.