Creating custom PMD rules

PMD has two extra features when compared to other static code review tools. The first is the cpdgui tool, which allows you to look for the code that has been cut-and-pasted from part of the code base to another. The second, and the one that we will explore in this recipe, is the ability to design custom bug discovery rules for Java source code using Xpath.

Getting ready

Make sure that you have installed the Jenkins PMD plugin (https://wiki.jenkins-ci.org/display/JENKINS/PMD+Plugin). Download and unpack the PMD distribution from http://pmd.sourceforge.net. Visit the PMD bin directory, and verify that you have the startup scripts designer.sh and designer.bat.

How to do it...

  1. Create a Maven project from the command line using: ...

Get Jenkins Continuous Integration Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.