26.27. PMD

26.27.1. Overview

The PMD Sensor is an Ant task that sends indications of errors code standards identified by PMD to the Hackystat server. The PMD sensor represents this metric data using the CodeIssue sensor data type, documented in Section 25.6, “CodeIssue”

PMD is a tool that automates the process of checking Java code find potential problems. It uses various rulesets to find possible bugs, dead code, suboptimal code, overcomplicated expressions, and duplicate code. Table 26.13, “PMD Metrics” lists the information gathered by the PMD sensor and the languages for which they are collected.

Table 26.13. PMD Metrics

MetricDescription
Source FileThe fully qualified name of the source file that was analyzed by pmd.
ErrorThe severity, message, and type of coding standard violation.

[Note]Note

Currently, this sensor sends information to the Hackystat server only when a source file contains violations. Thus, the Hackystat server analyses cannot distinguish between files that have no violations and files that have not had this tool invoked on them. This means that this CodeIssue data is potentially susceptible to "false negatives" during analysis.

26.27.2. Installation

26.27.2.1. Prerequisites

The PMD sensor requires Java 1.5.0 or later, Ant 1.6.5 or later, and PMD 3.4 or later.

26.27.2.2. Download and install PMD

Download and install PMD from its home page. Section 4.13, “Measurement: Source code quality with PMD” provides a recommended approach to PMD installation for use with Hackystat.

26.27.2.3. Download HackyInstaller and set your Hackystat Host and User Key

Follow the instructions in Chapter 2, Client-side configuration: Tool sensor installation to set your Hackystat host and user key.

26.27.2.4. Configure and install the PMD sensor

In the HackyInstaller main window, select the PMD sensor and press "Configure Selected Sensor". Figure 26.53, “ PMD sensor installer configuration window ” shows what the configuration window should look like after the path to Ant is set, the sensor is enabled, and the "Install" button has been pressed to install the sensor.

Figure 26.53.  PMD sensor installer configuration window


PMD sensor installer configuration window

This sensor supports the following properties and paths:

  • Enable PMD Sensor: This property controls whether the sensor is active or not. If not checked, the sensor will not collect or send data even if installed.

  • Ant home directory: This path specifies the top-level directory for Ant. The PMD sensor requires the placement of a sensor executable into Ant's lib/ directory.

26.27.2.5. Define Ant targets to run the PMD tool and the PMD sensor

Define targets in your build.xml file to analyze your source code files using PMD and send them to Hackystat using the pmd sensor. Example 26.64, “Example pmd.tool, pmd.report, and pmd.sensor targets” illustrates one possible definition of these targets.

Example 26.64. Example pmd.tool, pmd.report, and pmd.sensor targets

  <target name="pmd.tool" description="Runs PMD over the source code to check for problems.">
    <!-- Fail this target if PMD is not installed. -->
    <available file="${env.PMD_HOME}/lib/${pmd.jar}" property="pmd.available"/>
    <fail unless="pmd.available" message="Error: PMD_HOME not set or ${pmd.jar} not found."/>
    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
      <classpath>
        <fileset dir="${env.PMD_HOME}/lib">
          <include name="*.jar"/>
        </fileset>
      </classpath>
    </taskdef>

    <!-- Run PMD -->
    <mkdir dir="${pmd.dir}"/>
   <pmd rulesetfiles="basic,braces,clone,codesize,coupling,design,imports,junit,naming,strings" 
         shortFilenames="false" 
         targetjdk="1.4" 
         failuresPropertyName="pmd.failure.count"
         failonerror="${pmd.failonerror}"
         failOnRuleViolation="${pmd.failonerror}" >
      <formatter type="xml" toFile="${pmd.dir}/pmd.xml" />
      <fileset dir="${src.dir}" includes="**/*.java" />
    </pmd>    
  </target>

  <target name="pmd.report" description="Generates HTML reports on the PMD output.">
    <xslt in="${pmd.dir}/pmd.xml" style="${env.PMD_HOME}/etc/xslt/pmd-report-per-class.xslt" 
      out="${pmd.dir}/pmd-report-per-class.html" />
    <xslt in="${pmd.dir}/pmd.xml" style="${env.PMD_HOME}/etc/xslt/pmd-report.xslt" 
      out="${pmd.dir}/pmd-report.html" />
    <xslt in="${pmd.dir}/pmd.xml" style="${env.PMD_HOME}/etc/xslt/wz-pmd-report.xslt" 
      out="${pmd.dir}/wz-pmd-report.html" />
  </target>

  <target name="pmd.sensor" description="Sends CodeIssue data to Hackystat using the PMD sensor.">
    <!-- Define the pmd sensor taskdef, failing the build if the sensor is not installed. -->
    <available classname="org.hackystat.sensor.pmd.PmdSensor" property="pmd.sensor.available"/>
    <fail unless="pmd.sensor.available" message="Error: PMD sensor not installed."/>
    <taskdef name="hacky-pmd" classname="org.hackystat.sensor.pmd.PmdSensor"/>

    <hacky-pmd verbose="true">
      <fileset file="${pmd.dir}/pmd.xml"/>
    </hacky-pmd>
  </target>  

For more details on these targets, see Section 4.13, “Measurement: Source code quality with PMD”, which illustrates the installation and use of PMD on a sample Java system called StackyHack.

26.27.3. Installation verification

26.27.3.1. Verify verbose mode output

To verify your PMD sensor installation, invoke the target and check to see that data is sent to the server. Example 26.65, “Example PMD output” shows the shell output from an example run with verbose= "on".

Example 26.65. Example PMD output


C:\svn-csdl\StackyHack>ant pmd
Buildfile: build.xml

pmd:
      [pmd]
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\ClearStack.java 14      
Classes implementing Serializable should set a serialVersionUID
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\ClearStack.java 14      
Each class should declare at least one constructor
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\EmptyStackException.java 15      
Avoid variables with short names like Avoid variables with short names like e
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 16 
Classes implementing Serializable should set a serialVersionUID
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 16
Each class should declare at least one constructor
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 22
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 30
Parameter 'obj' is not assigned and could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 43
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 61
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 62
Consider simply returning the value vs storing it in local variable 'obj'
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 76
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 88
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 91
Avoid empty catch blocks
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java 111
Parameter 'args' is not assigned and could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 15      
Each class should declare at least one constructor
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 18      
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 18      
Perhaps 'one' could be replaced by a local variable.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 18      
Private field could be made final.  It is only initialized in the declaration or constructor.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 19      
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 19      
Perhaps 'two' could be replaced by a local variable.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 19      
Private field could be made final.  It is only initialized in the declaration or constructor.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 20      
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 20      
Perhaps 'three' could be replaced by a local variable.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 20      
Private field could be made final.  It is only initialized in the declaration or constructor.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 26      
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 30      
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 32      
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java 33      
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 13      
Each class should declare at least one constructor
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 16      
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 16      
Perhaps 'one' could be replaced by a local variable.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 16      
Private field could be made final.  It is only initialized in the declaration or constructor.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 17      
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 17      
Perhaps 'two' could be replaced by a local variable.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 17      
Private field could be made final.  It is only initialized in the declaration or constructor.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 18      
Found non-transient, non-static member. Please mark as transient or provide accessors.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 18      
Perhaps 'three' could be replaced by a local variable.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 18      
Private field could be made final.  It is only initialized in the declaration or constructor.
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 27      
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 43      
Local variable could be declared final
      [pmd] C:\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java 48      
Avoid empty catch blocks
     [xslt] Processing C:\svn-csdl\StackyHack\build\pmd\pmd.xml to C:\java\
svn-csdl\StackyHack\build\pmd\pmd-report-per-class.html
     [xslt] Loading stylesheet C:\java\pmd-3.3\etc\xslt\pmd-report-per-class.xslt
     [xslt] Processing C:\svn-csdl\StackyHack\build\pmd\pmd.xml to C:\java\svn-csdl\StackyHack\build\pmd\pmd-report.html
     [xslt] Loading stylesheet C:\java\pmd-3.3\etc\xslt\pmd-report.xslt
     [xslt] Processing C:\svn-csdl\StackyHack\build\pmd\pmd.xml to C:\java\svn-csdl\StackyHack\build\pmd\wz-pmd-report.html
     [xslt] Loading stylesheet C:\java\pmd-3.3\etc\xslt\wz-pmd-report.xslt
[hacky-pmd] Sensor enabled?: true
[hacky-pmd] Processing file: C:\svn-csdl\StackyHack\build\pmd\pmd.xml
[hacky-pmd] Hackystat data on 41 Code Issues sent to http://hackystat.ics.hawaii.edu/ (1 secs.)

BUILD SUCCESSFUL
Total time: 5 seconds
C:\svn-csdl\StackyHack>

The PMD sensor will output a different message if the data was not sent successfully.

26.27.3.2. List Sensor Data

Once you verify that PMD data is being sent from the client using verbose mode, login to your account on your Hackystat server, and use the "List Sensor Data" command on the Extras page to verify that FileMetric data for today's date was received by the server for the PMD tool, as illustrated in Figure 26.54, “ List Sensor Data with PMD data ”.

Figure 26.54.  List Sensor Data with PMD data


List Sensor Data with PMD data

26.27.4. Installation troubleshooting

26.27.4.1. Troubleshooting general client-server problems

The first step in troubleshooting your sensor installation is to verify that your Hackystat host and key settings are valid and that you can contact the Hackystat server, as described in Section 2.4, “HackyInstaller GUI: Setting and verifying the Hackystat host and user key”

26.27.4.2. Checking client-side logging

The PMD sensor writes out a file called pmd.0.log to the .hackystat/logs directory that can be useful in debugging your installation. Under normal conditions, this file should look similar to Example 26.66, “pmd.0.log file for PMD sensor”.

Example 26.66. pmd.0.log file for PMD sensor

Hackystat Version: 7.0.1201 (December 1 2005 14:18:13)
SensorShell started at: 12/04/2005 22:47:31
Type 'help' for a list of commands.
Host: http://hackystat.ics.hawaii.edu/ is available and key is valid.
Defined shell command: Dependency
Defined shell command: Issue
Defined shell command: CodeIssue
Defined shell command: EvolSdt
Defined shell command: Perf
Defined shell command: FileMetric
Defined shell command: ReviewIssue
Defined shell command: Activity
Defined shell command: Cli
Defined shell command: ReviewActivity
Defined shell command: Coverage
Defined shell command: UnitTest
Defined shell command: BuffTrans
Defined shell command: Commit
Defined shell command: Build
#> AutoSend [10]
AutoSend OK (set to 10 minutes)
AutoSend enabled every 10 minutes.
Checking for offline data to recover.
No offline data found.
#> CodeIssue [set, tool=Pmd]
set OK
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\ClearStack.java, type=MissingSerialVersionUID, data=severity=3,message=
Classes implementing Serializable should set a serialVersionUID
,line=14,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (1)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\ClearStack.java, type=AtLeastOneConstructor, data=severity=3,message=
Each class should declare at least one constructor
,line=14,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (2)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\EmptyStackException.java, type=ShortVariable, data=severity=3,message=
Avoid variables with short names like Avoid variables with short names like e
,line=15,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (3)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=MissingSerialVersionUID, data=severity=3,message=
Classes implementing Serializable should set a serialVersionUID
,line=16,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (4)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=AtLeastOneConstructor, data=severity=3,message=
Each class should declare at least one constructor
,line=16,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (5)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=22,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (6)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=MethodArgumentCouldBeFinal, data=severity=3,message=
Parameter 'obj' is not assigned and could be declared final
,line=30,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (7)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=43,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (8)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=61,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (9)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=UnnecessaryLocalBeforeReturn, data=severity=3,message=
Consider simply returning the value vs storing it in local variable 'obj'
,line=62,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (10)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=76,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (11)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=88,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (12)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=EmptyCatchBlock, data=severity=3,message=
Avoid empty catch blocks
,line=91,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (13)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\Stack.java, type=MethodArgumentCouldBeFinal, data=severity=3,message=
Parameter 'args' is not assigned and could be declared final
,line=111,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (14)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=AtLeastOneConstructor, data=severity=3,message=
Each class should declare at least one constructor
,line=15,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (15)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=18,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (16)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=SingularField, data=severity=3,message=
Perhaps 'one' could be replaced by a local variable.
,line=18,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (17)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=ImmutableField, data=severity=3,message=
Private field could be made final.  It is only initialized in the declaration or constructor.
,line=18,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (18)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=19,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (19)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=SingularField, data=severity=3,message=
Perhaps 'two' could be replaced by a local variable.
,line=19,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (20)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=ImmutableField, data=severity=3,message=
Private field could be made final.  It is only initialized in the declaration or constructor.
,line=19,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (21)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=20,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (22)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=SingularField, data=severity=3,message=
Perhaps 'three' could be replaced by a local variable.
,line=20,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (23)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=ImmutableField, data=severity=3,message=
Private field could be made final.  It is only initialized in the declaration or constructor.
,line=20,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (24)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=26,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (25)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=30,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (26)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=32,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (27)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestClearStack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=33,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (28)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=AtLeastOneConstructor, data=severity=3,message=
Each class should declare at least one constructor
,line=13,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (29)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=16,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (30)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=SingularField, data=severity=3,message=
Perhaps 'one' could be replaced by a local variable.
,line=16,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (31)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=ImmutableField, data=severity=3,message=
Private field could be made final.  It is only initialized in the declaration or constructor.
,line=16,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (32)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=17,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (33)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=SingularField, data=severity=3,message=
Perhaps 'two' could be replaced by a local variable.
,line=17,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (34)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=ImmutableField, data=severity=3,message=
Private field could be made final.  It is only initialized in the declaration or constructor.
,line=17,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (35)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=BeanMembersShouldSerialize, data=severity=3,message=
Found non-transient, non-static member. Please mark as transient or provide accessors.
,line=18,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (36)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=SingularField, data=severity=3,message=
Perhaps 'three' could be replaced by a local variable.
,line=18,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (37)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=ImmutableField, data=severity=3,message=
Private field could be made final.  It is only initialized in the declaration or constructor.
,line=18,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (38)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=27,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (39)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=LocalVariableCouldBeFinal, data=severity=3,message=
Local variable could be declared final
,line=43,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (40)
#> CodeIssue [add, runtime=1133772451007, fileName=C:\java\svn-csdl\StackyHack\src\edu\hawaii\stack\TestStack.java, type=EmptyCatchBlock, data=severity=3,message=
Avoid empty catch blocks
,line=48,column=,packageName=packageName=edu.hawaii.stack]
CodeIssue add OK (41)
#> send
Sending sensor data (12/04 22:47:32)
  Ping: Ping OK (contacted server http://hackystat.ics.hawaii.edu/ with valid key.)
  Dependency: Send OK (No entries to send.)
  AutoSend: AutoSend OK ('send' command ignored)
  Issue: Send OK (No entries to send.)
  CodeIssue: Send OK (41 entries)
  EvolSdt: Send OK (No entries to send.)
  Perf: Send OK (No entries to send.)
  FileMetric: Send OK (No entries to send.)
  ReviewIssue: Send OK (No entries to send.)
  Activity: Send OK (No entries to send.)
  Cli: Send OK (No entries to send.)
  ReviewActivity: Send OK (No entries to send.)
  Coverage: Send OK (No entries to send.)
  Commit: Send OK (No entries to send.)
  BuffTrans: Send OK (No entries to send.)
  UnitTest: Send OK (No entries to send.)
  Build: Send OK (No entries to send.)

26.27.4.3. Submit a trouble report

If none of the above troubleshooting activities solves your problem, then you should send an email to your Hackystat Administrator to request help. Please include in your email the following information:

  • The output from 'java -version'.

  • The output from 'java -jar sensorshell.jar -verify'.

  • The contents of your sensor.properties file.

  • The contents of the pmd.0.log file.

  • A description of the problem you are having.

26.27.5. Usage tips

26.27.5.1. Integrate PMD data collection into your development process

You probably don't want to have to invoke "ant pmd" manually each time you want metric data sent to Hackystat. It is better to have the pmd data calculated and sent to Hackystat automatically as a natural course of development. One strategy is to make the pmd target a dependent target of an "install" or "distribution" target so that structural data is recorded each time significant changes occur to the system. This provides a historical record of the structural evolution that can be later used by Hackystat analyses.

26.27.5.2. Disable verbose mode

Set verbose="off" once things are working correctly.

26.27.6. Uninstallation

To disable PMD data collection temporarily, invoke HackyInstaller, bring up the PMD configuration window, and uncheck the "Enable PMD sensor" property, and apply the setting. To permanently uninstall the PMD sensor, press the "Uninstall" button and remove the Build targets from your Ant build.xml files.