Introduction to PMD
PMD is a static rule set based Java source code analyzer that identifies potential problems.
It searches Java code for inefficient code, bugs,common coding problems, and other such issues. PMD can be used in the development environment through IDE integrations, or it can be incorporated directly into an Ant or Maven build.
PMD uses rules to perform the source code analysis, and the rules are grouped into rule sets.
Requirements
- Eclipse3.3 or later
- JRE/JDK1.5 or later
Installation
Update sites
Start Eclipse and open a project
Select "Help" - "Software Updates" - "Find and Install"
Click "Next", then click "New remote site"
Enter "PMD" into the Name field and URL : http://pmd.sf.net/eclipse
Click through the rest of the dialog boxes to install the plugin
Alternatively, you can download the latest zip file and follow the above procedures except for using "New local site" and browsing to the downloaded zip file.
Using the Plugin
To configure PMD, select Windows - Preferences - PMD.
Torun PMD, right-click on a project node and select PMD - Check code with PMD.
It will show the errors on files, if violations are found.
Bug description for PMD
For Bug description, Visit : http://pmd.sourceforge.net/rules/index.html
Customizing the rule set
1. Export rule set
Go to Windows - Preferences - PMD - Rules configuration
Click on “Export rule set...” button. Specify the file name for saving it.
(You can take backup of original exported rule-set file for future use.)
2. Modify rule set
Open the rule-set file and comment the rules, you do not want exclude. Like,
<!--
<ruleref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>
-->
And save the file.
3. Import modified rule set
Go to Windows > Preferences > PMD > Rules configuration
Click “clear all...” button to remove all rules.
Click “Import rule set...” button and select the modified rule-set file.
Check “Import by copy” checkbox.
Click OK to apply new rules.
Click OK, if it asks for full rebuild of code.
Restart the eclipse; clear all PMD violations and check for violations again.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.