Article Index

pmd_logo_small PMD

PMD is a static ruleset based Java source code analyzer that identifies potential problems like:

  • Possible bugs - Empty try/catch/finally/switch blocks.
  • Dead code - Unused local variables, parameters and private methods
  • Empty if/while statements
  • Overcomplicated expressions - Unnecessary if statements, for loops that could be while loops
  • Sub optimal code - wasteful String/String Buffer usage
  • Classes with high Cyclomatic Complexity measurements.
  • Duplicate code - Copied/pasted code can mean copied/pasted bugs, and decreases maintainability.

While PMD doesn't officially stand for anything, it has several unofficial names, the most appropriate probably
being Programming Mistake Detector. Typically, PMD errors are not true errors, but rather inefficient code,
i.e. the application could still function properly even if they were not corrected
. from WikiPedia

  • PMD Can be integrated with Eclipse (see below), Maven (maven-pmd-plugins), Ant (Ant task).
  • PMD is an engine, rulesets parse code and issue a message and level if rules are violated.
  • PMD is notable because you can write your own rules using XPath expressions over an XML version of the parse tree
  • PMD has a duplicate code detector CPD which is quite fast and accurate to locate dangerous CUT and Paste code sections.

List of rule sets

Basic JSF rules:

Basic JSP rules

Basic Rules

Braces Rules

Clone Implementation Rules

Code Size Rules

Controversial Rules

Coupling Rules

Design Rules

Finalizer Rules

Import Statement Rules

J2EE Rules

JavaBean Rules

JUnit Rules

Jakarta Commons Logging Rules

Java Logging Rules

Migration Rules

Migration15

MigratingToJava4

Naming Rules

Optimization Rules

Strict Exception Rules

String and StringBuffer Rules

Security Code Guidelines

Type Resolution Rules

Unused Code Rules

&160;