In Gradle Java projects, we can use PMD through the pmd plugin. To configure the rules that we want to use, there are two ways to do this:
- ruleSetFiles - Files of custom rules to be used. See the white paper for how to create a rule set file. Example: ruleSetFiles = files ("config / pmd / myRuleSet.xml")
- rulesSets Built-in rule sets are used. See the official list of built-in rule sets.
There are no problems with ruleSetFiles, can you find the names of the rules and add or exclude them, but there is no information about the rules in the documentation? Where to find the exact names? From what I found from other projects, the names are similar to the names from the PMD documentation, but lowercase. For instance:
Braces - > java-braces Clone - > java-clone Implementation - >java-implementation Code Size - > java-codesize
But this, as the Security Code Rules , is not converted to → java-securitycodeguidelines, but only in java-sunsecure . I found that names that work with PMD 5.1.1. are:
pmd { ruleSets = [ 'java-android', 'java-basic', 'java-braces', 'java-clone', 'java-codesize', 'java-comments', 'java-controversial', 'java-coupling', 'java-design', 'java-empty', 'java-finalizers', 'java-imports', 'java-j2ee', 'java-javabeans', 'java-junit', 'java-logging-jakarta-commons', 'java-logging-java', 'java-migrating', 'java-naming', 'java-optimizations', 'java-strictexception', 'java-strings', 'java-sunsecure', 'java-typeresolution', 'java-unnecessary', 'java-unusedcode' ] toolVersion = '5.1.1' ignoreFailures = true }
How do I find a mapping between the PMD names that are shown in their documentation and the Gradle names?