How do I generate PMD and CPD reports for a site?
Author: Deron Eriksson
Description: This maven tutorial describes how to generate PMD (Java code quality) and CPD (code duplication) reports for a site using the Maven PMD Plugin.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

Page: < 1 2

(Continued from page 1)

Now, let's look at the generated reports. The PMD Plugin generated the CPD and PMD reports. The JXR Plugin generated the Source Xref and Test Source Xref reports. The Javadoc Plugin generated the JavaDocs and Test JavaDocs reports. I'll focus on the CPD and PMD reports.

Generated Reports

Here we can see the CPD report. According to the report, the and files contain duplicate code. The report displays the line numbers of the duplications. The report is correct. I copy/pasted Howdy and renamed the class.

CPD Results

If I click the line numbers, I'm taking to the Xref document of the duplicated code.

Xref for Howdy class

Now, let's look at the PMD report. I put an unused local variable and an unused private method in my App class. The PMD Plugin found this issues and reported them here.

PMD Results

If I click a line number, I'm taken to the relevant line number in the Xref file for the JavaSW class.

Xref for App class
Page: < 1 2

Related Tutorials: