tumblr counter

PMD Eclipse Tutorial

PMD Eclipse Tutorial explains step by step details of installing and configuring PMD plugin with eclipse.

How to configure PMD plugin with eclipse?

How to generate PMD reports with eclipse?

What is PMD? How to use PMD?

PMD  stands for Programming Mistake Detector. It is a free source code analysis tool which helps you to find the bugs in your java code and improve the code quality. PMD helps to find empty try/catch/finally statements, while/if statements, unnecessary object creation etc.

PMD warning and problems are not exactly errors, but shows that particular code need to be improved

Following plugins are available for PMD

  1. Maven PMD plugin
  2. NetBeans PMD plugin
  3. JBuilder PMD plugin
  4. JDeveloper PMD plugin
  5. IntelliJ PMD plugin
Note

Findbugs is another source code analysis tool, you can configure FindBugs plugin same as PMD, please refer this article for using FindBugs FindBugs In Eclipse Tutorial

If you interested on Eclipse Checkstyle Tutorial (another code analysis tool), You can follow Eclipse Checkstyle Tutorial

If you interested on Sonar Eclipse Plugin (another source code analysis tool), You can follow Eclipse Sonar Tutorial

Required Libraries

You need to download

  1. Eclipse 4.2
  2. PMD

You can install the PMD Eclipse plugin using Eclipse update manager from the following links

  1. http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/

PMD Eclipse Installation

For Installing PMD Plugin from eclipse, select Help->Install New Software Then click add, then provide Name and Location according to the following screenshot

PMD Installation

Then select the PMD version click next and accept the license details, it will install the PMD

PMD Eclipse Configuration

After install, you can configure PMD from eclipse, Window->Preferences->Java->PMD

Here you can apply PMD Rules, in order to utilizing different rules on PMD bug patterns, you can also configure different reports here

PMD Configuration

Using PMD Eclipse Plugin

Finding bugs using PMD, you need to create a java project and add the following class into src

package test.pmd;

//PMD Eclipse Tutorial
public class PMDTest {
 
public static void main(String args[]) {
   
PMDTest.CALL_METHOD("hello");
    PMDTest.CallHello
();
 
}

 
public static void CALL_METHOD(String INPUT_PARAMETER) {
   
System.out.println(INPUT_PARAMETER);
 
}

 
public static void CallHello() {
   
System.out.println("Hello PMD World!");
 
}
}

Running PMD

Then, Build the project using Project->Build Project. Right click on the project, and run the PMD according to following screenshot.

Running PMD




1 2 Next






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