简体   繁体   中英

Configure same PMD ruleset for eclipse-pmd as gradle PMD uses - Which ruleset is used for net.sourceforge.pmd:pmd-java

I have PMD checks in my build.gradle like this:

apply plugin: "pmd"

dependencies {
  pmd "net.sourceforge.pmd:pmd-java:5.5.+"
}
/*** PMD ***/

pmd {
    ignoreFailures = true
}

tasks.withType(Pmd) {
    excludes = ["**/gen/*"]
    reports {
        xml.enabled = true
        html.enabled = true
    }
}

Which ruleset is used here?

I would like to configure the same ruleset for the eclipse PMD plugin (Project Properties -> PMD - Add). Ideally eclipse project is configured by gradle to have the correct settings.

The default config for Gradle is using java-basic ( source )

However, this is a very conservative approach that takes little advantage of all PMD has to offer.

My personal advice as a PMD maintainer is that you:

  1. Review all rules available at https://pmd.github.io/pmd-5.8.1/pmd-java/rules/index.html
  2. Create your own ruleset including those rules you agreed with, with all extra properties you may want to change from defaults.

Both Gradle and the PMD Eclipse plugin can load rules from a ruleset on file, making it easy to keep both of them in sync at all times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM