PMD

The PMD bundled plugin scans Java source code and other languages, and looks for potential problems such as bugs, dead code, suboptimal code, overcomplicated expressions, and duplicate code. Use the plugin in your code review process to find common programming flaws.

PMD is configurable and can find many different issues.

Configuration

The PMD libraries are embedded in the plugin, so there are no external tools to install.

Because PMD operates on source code files, add the PMD plugin to a chain that populates a workspace.

When you add the PMD plugin step to a chain, specify the following configuration details:

Field Description
Title Enter a name for the step. Default: PMD.
Source folder

Enter the relative stream directory against which to run the analysis, for example:

src/main/java

Command-line option (should be a relative path): -dir

Rulesets location

Select a ruleset location:

  • Use built-in rulesets (default).
  • Use local rulesets.
  • Use rulesets stored in the stream.
Rulesets

Enter a comma-separated list of ruleset names, for example:

rulesets/java/basic.xml

In addition to standard rulesets, you can use a custom ruleset.

Command-line option: -rulesets

Project classpath

(Optional) Specify the classpath for libraries used by the source code, for example:

commons-collections.jar;derby.jar

Command-line option: -auxclasspath

Source encoding

(Optional) Specify the source code encoding, for example, UTF-8.

Command-line option: -encoding

Source language

(Optional) Specify the source code language, for example, Java.

Command-line option: -language

Language version

(Optional) Specify the version of the source code language.

Command-line option: -version

Show suppressed

(Optional) Select to show suppressed findings.

Example: false

Command-line option: -showsuppressed

Suppress marker

(Optional) Specify the suppress marker, for example, NOPMDNEWMARKER.

Command-line option: -suppressmarker

The PMD command-line option shows how each configuration field maps to the PMD command-line tool.

Tip: The PMD plugin and PMD command-line tool use the PMD core library. Any options that you can pass to the PMD command-line tool you can also pass to the PMD plugin.

Back to top

See also: