Xelian
Xelian

Reputation: 17218

How to find PMD Rulesets names in Gradle >2.0

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:

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?

Upvotes: 7

Views: 3732

Answers (1)

dbyron
dbyron

Reputation: 511

The docs for RuleSetReferenceId are helpful, as is I believe this directory in the source tree. Basically put java- in front of any of these files to turn on the rules there.

Upvotes: 3

Related Questions