Using Rule Sets

The PMD plugin uses five default rule sets: basic.xml, empty.xml, imports.xml, unnecessary.xml and unusedcode.xml. These rule sets are bundled in the PMD code analysis tool (see the ruleset index for java, the ruleset index for javascript and ruleset index for jsp). To use other rule sets, you can configure it in the plugin as shown below.

The rule sets may reside in the classpath, filesystem or at a URL. For rule sets that are bundled with the PMD tool, you do not need to specificy the absolute path of the file. It will be resolved by the plugin. But if the rule set is a custom rule set, you need to specify its absolute path.

Note: Starting with PMD 5.0 and Maven PMD Plugin 3.0 the paths to the bundled rule sets for the Java language were changed from /rulesets/xyz.xml to /rulesets/java/xyz.xml. So when upgrading to Maven PMD Plugin 3.0 you may need to alter your plugin configuration.

            <!-- Two rule sets that come bundled with PMD -->
            <!-- Custom local file system rule set -->
            <!-- Custom remote rule set accessed via a URL -->