PMD has long been a great report to find out many useful details of your code base.

I find that the default ruleset does not contain some checks that I find very useful especially when I have more junior developers. I can catch many problematic errors.

<?xml version=”1.0″?>

&lt;ruleset name="Custom ruleset"

 This ruleset checks my code for bad stuff

 &lt;!-- Here's some rules we'll specify one at a time --&gt;
 &lt;rule ref="rulesets/basic.xml"/&gt;

 &lt;!-- We want to customize this rule a bit, change the message and raise the priority  --&gt;
 &lt;rule ref="rulesets/basic.xml/EmptyCatchBlock"
 message="Must handle exceptions"&gt;

 &lt;rule ref="rulesets/codesize.xml"/&gt;
 &lt;rule ref="rulesets/codesize.xml/CyclomaticComplexity"&gt;
         &lt;property name="reportLevel" value="5"/&gt;
 &lt;rule ref="rulesets/controversial.xml" /&gt;
 &lt;rule ref="rulesets/coupling.xml" /&gt;

 &lt;rule ref="rulesets/design.xml" /&gt;
 &lt;rule ref="rulesets/imports.xml" /&gt;
 &lt;rule ref="rulesets/logging-java.xml" /&gt;

 &lt;rule ref="rulesets/optimizations.xml" /&gt;
 &lt;rule ref="rulesets/strictexception.xml" /&gt;
 &lt;rule ref="rulesets/strings.xml" /&gt;
 &lt;rule ref="rulesets/sunsecure.xml" /&gt;
 &lt;rule ref="rulesets/typeresolution.xml" /&gt;
 &lt;rule ref="rulesets/unusedcode.xml" /&gt;

 &lt;rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" /&gt;
 &lt;rule ref="rulesets/unusedcode.xml/UnusedPrivateField" /&gt;

 &lt;!-- Note we want everything from braces.xml except WhileLoopsMustUseBraces --&gt;
 &lt;rule ref="rulesets/braces.xml"&gt;
     &lt;exclude name="WhileLoopsMustUseBraces"/&gt;

I uploaded my configuration to my server (, then I can access this on any project I am working on:

If you find you like your PMD a bit different, just customize the rules and put onto your webserver, then you can carry your rules with you.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting.

View all posts

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense