Using pmd-5.0.1. I have some custom rulesets:
<target name="pmd">
<condition property="rules.file" else="${data}\pmdrules.xml,${data}\madcustompmdrules.xml">
<isset property="rules.file"/>
</condition>
<pmd rulesetfiles="${rules.file}">
<formatter type="xml" toFile="${report.file}"/>
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
The rulesets reference basic rules like this:
<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>
<rule ref="rulesets/basic.xml/JumbledIncrementer"/>
<rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
<rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
However, when running this ant target I get:
java.lang.RuntimeException: Couldn't find the class Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH.
Shouldn't basic.xml be part of the jar file? What am I missing?
Looks like I was basing my rules off an outdated version of PMD. Most of them are located at rulesets/java/basic.xml/...
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With