Problem with PMD plugin in Gradle #4145
-
Hi guys, I have a question. Gradle version: 7.4 In my project I’m using pmd plugin. If you want to remove this file, you must clear ruleSets property: I define the rules by following the pmd docs, for example: <rule ref="category/java/errorprone.xml/CloneMethodMustBePublic"/>
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/>
<rule ref="category/java/errorprone.xml/ProperCloneImplementation"/>
<rule ref="category/java/errorprone.xml/CloneThrowsCloneNotSupportedException"/> Can someone explain what is happening :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
By the way, this should be easier with gradle 8. They improved the configuration (see gradle/gradle#22211) According to the current documentation https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.Pmd.html#org.gradle.api.plugins.quality.Pmd there seems to be a third parameter called I tried it out myself and it works as it should - only the custom ruleset is used:
complete ruleset custom-ruleset.xml<ruleset name="Custom ruleset for tests"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>Custom ruleset for tests</description>
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic"/>
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/>
<rule ref="category/java/errorprone.xml/ProperCloneImplementation"/>
<rule ref="category/java/errorprone.xml/CloneThrowsCloneNotSupportedException"/>
</ruleset>
What error/message do you get? Note, that you use rules from errorprone in your custom ruleset, so e.g. you should expect "CloneMethodMustBePublic" but not other rules from errorprone (such as AssignmentInOperand). |
Beta Was this translation helpful? Give feedback.
-
Hi @adangel, thank you for your reply. Thank you again, have a nice day :) |
Beta Was this translation helpful? Give feedback.
By the way, this should be easier with gradle 8. They improved the configuration (see gradle/gradle#22211)
According to the current documentation https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.Pmd.html#org.gradle.api.plugins.quality.Pmd there seems to be a third parameter called
ruleSetConfig
. Maybe settingruleSets = []
and using ruleSetConfig instead of ruleSetFiles helps?I tried it out myself and it works as it should - only the custom ruleset is used:
complete ruleset custom-ruleset.xml