##### Overview

- Download PMD 5.0.4
- What's new in PMD 5.0.4
- PMD in the news
- PMD-related products and books
- Best practices
- Future directions
- Similar projects
- Credits
- License
- What does 'PMD' mean?

##### Usage

- Installation
- Command line usage
- Ant task usage
- Maven plugin usage
- Mvn plugin usage
- IDE plugin usage
- Suppressing warnings
- Finding duplicated code
- JSP support

##### Customizing PMD

- Compiling PMD
- How to write a rule
- Writing XPath rules
- How to make a rule set
- How it works
- Rule guidelines
- PMD developers information
- PMD Release Process

##### For example

- Run PMD on a Sourceforge project

##### Misc.

- XPath tutorial (Gregorian)

##### Rule Sets

- ecmascript
  - Basic Ecmascript
  - Braces
  - Unnecessary
- java
  - Android
  - Basic
  - Braces
  - Clone Implementation
  - Code Size
  - Comments
  - Controversial
  - Coupling
  - Design
  - Empty Code
  - Finalizer
  - Import Statements
  - J2EE
  - JavaBeans
  - JUnit
  - Jakarta Commons Logging
  - Java Logging
  - Migration
  - Naming
  - Optimization
  - Strict Exceptions
  - String and StringBuffer
  - Security Code Guidelines
  - Type Resolution
  - Unnecessary
  - Unused Code
- jsp
  - Basic JSF
  - Basic JSP
- xml
  - Basic XML
- xsl
  - XPath in XSL

##### Project Documentation

- Project Information
- Project Reports

## Unused Code

The Unused Code ruleset contains rules that find unused or ineffective code.

### UnusedPrivateField

Since: PMD 0.1

Detects when a private field is declared and/or assigned a value, but not used.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedPrivateFieldRule

Example(s):

    public class Something {
      private static int FOO = 2; // Unused
      private int i = 5; // Unused
      private int j = 6;
      public int addOne() {
        return j++;
      }
    }

This rule has the following properties:

Name | Default Value | Description
violationSuppressRegex |  | Suppress violations with messages matching a regular expression
violationSuppressXPath |  | Suppress violations on nodes which match a given relative XPath expression.

### UnusedLocalVariable

Since: PMD 0.1

Detects when a local variable is declared and/or assigned, but not used.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedLocalVariableRule

Example(s):

    public class Foo {
    	public void doSomething() {
    		int i = 5; // Unused
    	}
    }

This rule has the following properties:

Name | Default Value | Description
violationSuppressRegex |  | Suppress violations with messages matching a regular expression
violationSuppressXPath |  | Suppress violations on nodes which match a given relative XPath expression.

### UnusedPrivateMethod

Since: PMD 0.7

Unused Private Method detects when a private method is declared but is unused.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedPrivateMethodRule

Example(s):

    public class Something {
    	private void foo() {} // unused
    }

This rule has the following properties:

Name | Default Value | Description
violationSuppressRegex |  | Suppress violations with messages matching a regular expression
violationSuppressXPath |  | Suppress violations on nodes which match a given relative XPath expression.

### UnusedFormalParameter

Since: PMD 0.8

Avoid passing parameters to methods or constructors without actually referencing them in the method body.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedFormalParameterRule

Example(s):

    public class Foo {
    	private void bar(String howdy) {
    	// howdy is not used
    	}
    }

This rule has the following properties:

Name | Default Value | Description
violationSuppressRegex |  | Suppress violations with messages matching a regular expression
violationSuppressXPath |  | Suppress violations on nodes which match a given relative XPath expression.
checkAll | false | Check all methods, including non-private ones

### UnusedModifier

Since: PMD 1.02

Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedModifierRule

Example(s):

    public interface Foo {
      public abstract void bar(); 		// both abstract and public are ignored by the compiler
      public static final int X = 0; 	// public, static, and final all ignored
      public static class Bar {} 		// public, static ignored
      public static interface Baz {} 	// ditto
    }
    public class Bar {
      public static interface Baz {} // static ignored
    }

This rule has the following properties:

Name | Default Value | Description
violationSuppressRegex |  | Suppress violations with messages matching a regular expression
violationSuppressXPath |  | Suppress violations on nodes which match a given relative XPath expression.