- Possible bugs - empty try/catch/finally/switch statements
- Dead code - unused local variables, parameters and private methods
- Suboptimal code - wasteful String/StringBuffer usage
- Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
- Duplicate code - copied/pasted code means copied/pasted bugs
Follow the below steps to integrate the plugin in Eclipse:
If you are behind a corporate firewall, set the proxy in Eclipse.
Window -> Preferences -> General -> Network Conncetions.
Select Manual proxy configuration.
HTTP Proxy :xxx.yyy.mmm.nnn
- Navigate to Help | Software Updates | Find and Install...
- Select "Search for new features to install" and click Next
- Click New Remote Site...
- Enter a name (PMD) and the URL http://pmd.sourceforge.net/eclipse

- In Sites to include in search check PMD and click Finish
- In the Search Results dialog check PMD for Eclipse 3 3.1.0 and click Next

- Accept the terms of the license agreements and click Next
- Click Finish.
- Wait for Eclipse to download the required jar files, then click Install
- Restart the workbench. This will load the PMD plugin.
- Navigate to Window | Show View | Other...
- Select PMD | PMD Violations
- PMD Violations view should appear at the bottom pane
Set up Preferences
- Download the XMl ruleset file to your workspace directory.
- Windows ->Preferences -> PMD -> Rules Configuration
- Clear All
- Confirm by clicking OK
- Import rule set...
- Browse
- Select the file you downloaded above
- Click OK to complete import
- Click OK to close Windows -> Preferences
- When prompted to perform a full rebuild, select yes.
How to use it?
Before launching Eclipse make sure you have enough memory for PMD. This is particularly important when analyzing large projects. In these situations PMD tends to be memory-hungry. Hence, make sure to start with as much memory as you can afford, for example 512M (eclipse.exe -vmargs -Xmx512M)

If PMD Violations view is not open navigate to Window | Show View | Other... and select PMD | PMD Violations
More -> http://pmd.sourceforge.net/
No comments:
Post a Comment