Why PMD?

854206_f3d1_2

For Java developers it is good opportunity to check whether they are following standard programming principles? For most Java development projects going on these days the answer would be to use “PMD”. Basically PMD is Programming Mistake Detector.  There are a lot many tools that PMD competes with i.e Checkstyle, FindBugs, Hammurapi, Soot, Squale etc.

PMD  identifies potential problems in the code like:

  1. Possible bugs – empty try/catch/finally/switch statements
  2. Dead code – unused local variables, parameters and private methods
  3. Suboptimal code – wasteful String/StringBuffer usage
  4. Overcomplicated expressions – unnecessary if statements, for loops that could be while loops
  5. Duplicate code – copied/pasted code means copied/pasted bugs

PMD is integrated with JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, and Emacs.

Configuring PMD for Eclipse

Quickly configure it with your Eclipse installation.

  1. Start Eclipse.
  2. Select the Help>Software Updates>Find and Install… menu item.
  3. Select “Search for new features to install” option and click Next.
  4. Click New Remote Site…
  5. Enter the URL http://pmd.sourceforge.net/eclipse
  6. Select this new site in the Sites to include in search list and click Next.
  7. Select PMD for Eclipse 3 and Apache Xerces in the “Select the features to install” list and click Next.
  8. Accept the terms of the license agreements and click Next.
  9. Verify that the install location is your Eclipse installation directory, otherwise select the correct one, click Finish.
  10. A warning appear telling the feature is not signed. Ignore and click Install to continue.
  11. Accept to restart the workbench to load PMD into the workbench.
  12. Right click on java file and try to check code using PMD.

Source

http://pmd.sourceforge.net/

http://www.javagyan.com/

Happy Coding….

2261total visits,2visits today

Leave a Reply

Your email address will not be published. Required fields are marked *