Reputation: 55
This might be a fairly straightforward thing, but i'm getting frustrated with my inability to figure it out. I've added a PMD plugin for maven to my pom and now i want to add some rulesets. How do I match the ones listed in the index, with the XML file I need to specify in my pom?
For example, How do I know that from The PMD ruleset index: http://pmd.sourceforge.net/pmd-4.3.0/rules/index.html
If i want to use the java logging ruleset that i need to add
<ruleset>rulesets/java/logging-java.xml</ruleset>
to my pom? There seems to be no mapping between the ruleset name in the index and the XML file name you need to specify in your POM. What am i missing here?
(I only figured the one above out by stumbling onto this question that seemed to have quite a few listed: How to included bundled rulesets in maven pmd plugin)
Upvotes: 2
Views: 897
Reputation: 3295
The file name and the ruleset name are only weakly related. I don't think there is a scheme that relates them. They are just names the developers working on them picked. The rulesets/java/logging-java.xml
is a good example of this as the name of the rule set is Java Logging and the filename is logging-java.
PMD resolves the paths bundled with it by loading the path as a resource. The latest bundled rulesets for Java are https://github.com/pmd/pmd/tree/master/pmd-java/src/main/resources/rulesets/java
I had trouble disabling a rule in a ruleset. I eventually worked out that the rule had been moved to a different ruleset in the version I was using. The generated XML report has a version attribute that pointed me at the correct version. You'll need to make sure that you are looking at the relevant index for the version you are using. I don't think the ruleset index you are looking at is for the version of PMD you are using.
If I look at http://pmd.sourceforge.net/pmd-5.2.3/pmd-java/rules/index.html and ignore the links in the article body. The links in the left hand menu under Rule Sets > Java are to HTML documents that have the same names as the XML rulesets.
The page http://pmd.sourceforge.net/pmd-5.2.3/pmd-java/rules/java/logging-java.html documents the ruleset loaded from ruleset/java/logging-java.xml
.
Upvotes: 3