In Gradle's Java projects we can use PMD via pmd
plugin. To configure the rules which we want to use can do it in two ways:
- ruleSetFiles - The custom rule set files to be used. See the official documentation for how to author a rule set file. Example: ruleSetFiles = files("config/pmd/myRuleSet.xml")
- ruleSetsThe built-in rule sets to be used. See the official list of built-in rule sets.
With ruleSetFiles there is no problem you can find the names of the rules and to add or exclude ones, but in the documentation there is no information about the ruleStes? From where to find the exact names? From what I found from another projects the names are similar to the names from the PMD documentation but lower case. For example:
Braces - > java-braces
Clone - > java-clone
Implementation - >java-implementation
Code Size - > java-codesize
But this like Security Code Guidelines do not transform in -> java-securitycodeguidelines but just in java-sunsecure. I found that the names which works 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 to find mapping between PMD names which are shown in their documentation and Gradle names?