[GRADLE-2706] With Gradle 1.5 - PMD applying basic rules even when they are not included in our rule set files Created: 14/Mar/13  Updated: 07/May/13  Resolved: 15/Mar/13

Status: Resolved
Project: Gradle
Affects Version/s: 1.5-rc-1
Fix Version/s: 1.5-rc-2

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

We have pmdMain configuration like this:

pmdMain

{ ruleSets = [] ruleSetFiles = files([ "$projectRoot/buildtools/pmd-rules/strings.xml", "$projectRoot/buildtools/pmd-rules/strictexception.xml", "$projectRoot/buildtools/pmd-rules/optimizations.xml", "$projectRoot/buildtools/pmd-rules/migrating.xml", "$projectRoot/buildtools/pmd-rules/logging-java.xml", "$projectRoot/buildtools/pmd-rules/imports.xml", "$projectRoot/buildtools/pmd-rules/design.xml", "$projectRoot/buildtools/pmd-rules/coupling.xml", "$projectRoot/buildtools/pmd-rules/controversial.xml", "$projectRoot/buildtools/pmd-rules/codesize.xml", "$projectRoot/buildtools/pmd-rules/clone.xml", "$projectRoot/buildtools/pmd-rules/basic.xml" ]) }

After 1.5 upgrade builds have started failing with rules not included in our rule set files. For example:
[Basic Rules.CollapsibleIfStatements] - These nested if statements could be combined

This rule is not defined in any of our ruleset files. Any help is appreciated.



 Comments   
Comment by Gradle Forums [ 14/Mar/13 ]

Looks like a regression to me, and so far I haven't found a workaround. We'll keep you informed.

Comment by Jonathan Baker [ 07/May/13 ]

I am experiencing this problem with both gradle 1.5 and gradle 1.6 on a mac.

bakerj:jss bakerj$ gradle --version

------------------------------------------------------------
Gradle 1.5
------------------------------------------------------------

Gradle build time: Wednesday, March 27, 2013 1:51:06 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_17 (Oracle Corporation 23.7-b01)
OS: Mac OS X 10.8.3 x86_64
bakerj:jss bakerj$ gradle --version

------------------------------------------------------------
Gradle 1.6
------------------------------------------------------------

Gradle build time: Tuesday, May 7, 2013 9:12:14 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_17 (Oracle Corporation 23.7-b01)
OS: Mac OS X 10.8.3 x86_64

It is a multi-module project. And my build script has the following relevant pmd settings:

project.ext {
    javaJdkHome = '/usr'
    javaVersion = '1.6'

//    Plugin and Tool version
    pmdVersion = '5.0.4'
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'pmd'

    compileJava {
        sourceCompatibility = project.javaVersion
        targetCompatibility = project.javaVersion
        options.fork = true
        options.forkOptions.executable = "${project.javaJdkHome}/bin/javac"
    }

    pmd {
        targetJdk = project.javaVersion
        toolVersion = project.pmdVersion
        sourceSets = [sourceSets.main]
        ruleSetFiles = files("${rootProject.projectDir}/config/pmd/rulesets/ruleset.xml")
//        ruleSets = ["${rootProject.projectDir}/config/pmd/rulesets/ruleset.xml"]
    }
}

Changing the ruleSetFiles configuration to the ruleSets configuration does fix the problem, but I thought I should comment that it may still be happening for others.

Generated at Wed Jun 30 12:29:16 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.