Full reference for PMD's command-line interface, including options, output formats and supported languages
Edit me

Options

The tool comes with a rather extensive help text, simply running with -help!

Option Description Default value Applies to
-rulesets
-R
Required Comma-separated list of ruleset or rule references.
-dir
-d
Required Root directory for the analyzed sources.
-format
-f
Output format of the analysis report. The available formats are described [here](#available-report-formats). text
-auxclasspath Specifies the classpath for libraries used by the source code. This is used to resolve types in source files. Alternatively, a `file://` URL to a text file containing path elements on consecutive lines can be specified. Java
-benchmark
-b
Enables benchmark mode, which outputs a benchmark report upon completion. The report is sent to standard error. false
-cache Specifies a location for the analysis cache file to use. This can greatly improve analysis performance and is **highly recommended**.
-debug
-verbose
-D
-V
Debug mode. Prints more log output. false
-encoding
-e
Specifies the character set encoding of the source code files PMD is reading. The valid values are the standard character sets of `java.nio.charset.Charset`. UTF-8
-failOnViolation
--failOnViolation
Specifies whether PMD exits with non-zero status if violations are found. By default PMD exits with status 4 if violations are found. Disable this feature with `-failOnViolation false` to exit with 0 instead and just output the report. true
-filelist Path to file containing a comma delimited list of files to analyze. If this is given, then you don't need to provide `-dir`.
-help
-h
-H
Display help on usage. false
-language
-l
Specify the language PMD should use.
-minimumpriority
-min
Rule priority threshold; rules with lower priority than configured here won't be used. 5
-norulesetcompatibility Disables the ruleset compatibility filter. The filter is active by default and tries to automatically "fix" old ruleset files with old rule names false
-no-cache Explicitly disables incremental analysis. This switch turns off suggestions to use Incremental Analysis, and causes the `-cache` option to be discarded if it is provided. false
-property
-P
Specifies a property for the report renderer. The option can be specified several times. []
-reportfile
-r
Path to a file in which the report output will be sent. By default the report is printed on standard output.
-shortnames Prints shortened filenames in the report. false
-showsuppressed Causes the suppressed rule violations to be added to the report. false
-stress
-S
Performs a stress test. false
-suppressmarker Specifies the comment token that marks lines which PMD should ignore. NOPMD
-threads
-t
Sets the number of threads used by PMD. Set threads to `0` to disable multi-threading processing. 1
-uri
-u
Database URI for sources. If this is given, then you don't need to provide `-dir`. PLSQL
-version
-v
Specify the version of a language PMD should use.

Exit Status

Please note that if PMD detects any violations, it will exit with status 4 (since 5.3). This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks.

0Everything is fine, no violations found
1Couldn't understand command-line parameters or PMD exited with an exception
4At least one violation has been detected, unless -failOnViolation false is set.

Supported Languages

Available Report Formats

PMD comes with many different renderers. The mnemonics in bold are used to select them on the command line, as arguments to the -format option. Some formats accept properties, which can be specified with the -property option on the command-line.

  • codeclimate: Renderer for Code Climate JSON format.

  • csv: Comma-separated values tabular format.

    Properties:

    • problem: Include problem column. Default: true.
    • package: Include package column. Default: true.
    • file: Include file column. Default: true.
    • priority: Include priority column. Default: true.
    • line: Include line column. Default: true.
    • desc: Include description column. Default: true.
    • ruleSet: Include Rule set column. Default: true.
    • rule: Include Rule column. Default: true.
  • emacs: GNU Emacs integration.

  • html: HTML format.

    Properties:

    • linePrefix: Prefix for line number anchor in the source file.
    • linkPrefix: Path to HTML source.
  • ideaj: IntelliJ IDEA integration.

    Properties:

    • classAndMethodName: Class and method name, pass .method when processing a directory.
    • sourcePath:
    • fileName:
  • summaryhtml: Summary HTML format.

    Properties:

    • linePrefix: Prefix for line number anchor in the source file.
    • linkPrefix: Path to HTML source.
  • text: Text format.

  • textcolor: Text format, with color support (requires ANSI console support, e.g. xterm, rxvt, etc.).

    Properties:

    • color: Enables colors with anything other than false or 0. Default: yes.
  • textpad: TextPad integration.

  • vbhtml: Vladimir Bossicard HTML format.

  • xml: XML format.

    Properties:

    • encoding: XML encoding format, defaults to UTF-8.
  • xslt: XML with a XSL transformation applied.

    Properties:

    • encoding: XML encoding format, defaults to UTF-8.
    • xsltFilename: The XSLT file name.
  • yahtml: Yet Another HTML format.

    Properties:

    • outputDir: Output directory.

Incremental Analysis

Ever since PMD 5.6.0, PMD has been able to perform Incremental Analysis.

When performing Incremental Analysis for the first time, PMD will cache analysis data and results. This allows subsequent analysis to only look into those files that are new / have changed. For a typical development environment, where you are only changing a few files at a time, this can reduce analysis time dramatically.

The generated report will be exactly the same as it would if running without incremental analysis. Files included in the final report will reflect exactly those files in your filesystem. Even if untouched, files with violations will be listed with full detail.

Enabling Incremental Analysis

Incremental analysis is enabled automatically once a location to store the cache has been defined. From Command Line that is done through the -cache argument, but support for the feature is available for tools integrating PMD such as Ant, Maven, and Gradle.

Tags: userdocs