With PMD 5.5.1 if I include a batch of rules (e.g., <rule ref="rulesets/java/design.xml"/>) and then attempt to further customize rules from that rule set to change the priority, I find that I can increase the priority, but I cannot decrease it. However if I list out each rule separately, without including the complete set, I can go in either direction, up or down.
Is this intentional behavior? It would be nice to have the flexibility to include the whole set, and then customize individual rule priority in either direction, not just up.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've also observed that if I exclude a rule from a ruleset, then include it by itself later with a customized priority, the rule runs twice, one as part of the ruleset from which it was excluded, with its original priority, and then again by itself with the customized priority.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Nick,
this sounds like a bug - not sure. Can you post the complete ruleset, you are using?
In general, adding a batch of rules (with excluding one rule) and adding the excluded rule with a different priority should work. It's important, that the batch of rules is in the ruleset file first, otherwise the rule is using the default priority again.
PMD is just reading your custom ruleset from top to down and stupidly executing, what's
in the file: Import all rules from coupling.xml except for LawOfDemeter and later on
import again all rules from coupling.xml, this time including LawOfDemeter.
Interestingly, PMD does not have a problem if the rules are imported twice. This case is
silently ignored. But maybe PMD should raise an error instead? WDYT?
Regards,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
With PMD 5.5.1 if I include a batch of rules (e.g., <rule ref="rulesets/java/design.xml"/>) and then attempt to further customize rules from that rule set to change the priority, I find that I can increase the priority, but I cannot decrease it. However if I list out each rule separately, without including the complete set, I can go in either direction, up or down.
Is this intentional behavior? It would be nice to have the flexibility to include the whole set, and then customize individual rule priority in either direction, not just up.
I've also observed that if I exclude a rule from a ruleset, then include it by itself later with a customized priority, the rule runs twice, one as part of the ruleset from which it was excluded, with its original priority, and then again by itself with the customized priority.
Hi Nick,
this sounds like a bug - not sure. Can you post the complete ruleset, you are using?
In general, adding a batch of rules (with excluding one rule) and adding the excluded rule with a different priority should work. It's important, that the batch of rules is in the ruleset file first, otherwise the rule is using the default priority again.
It reminds be a bit of https://sourceforge.net/p/pmd/bugs/1537/ and http://stackoverflow.com/questions/40299075/custom-pmd-ruleset-not-working
Quoting from there:
Regards,
Andreas