##### Overview

- Download PMD 4.2.5
- What's new in PMD 4.2.5
- 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

##### For example

- Run PMD on a Sourceforge project

##### Rule Sets

- Index
- Android
- Basic
- Braces
- Code Size
- Clone
- Controversial
- Coupling
- Design
- Finalizers
- Import Statements
- J2EE
- Javabeans
- JUnit Tests
- Logging (Java)
- Logging (Jakarta)
- Migrating
- Naming
- Optimizations
- Strict Exceptions
- Strings
- Sun Security
- Unused Code
- Java Server Pages
- Java Server Faces

##### Project Documentation

- About
- Project Info
- Project Reports
- Development Process

##### Legend

- External Link
- Opens in a new window

## Unused Code Rules

The Unused Code Ruleset contains a collection of rules that find unused 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.rules.UnusedPrivateFieldRule

Example:

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

### 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.rules.UnusedLocalVariableRule

Example:

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

### 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.rules.UnusedPrivateMethodRule

Example:

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

### UnusedFormalParameter

Since: PMD 0.8

Avoid passing parameters to methods or constructors and then not using those parameters.

This rule is defined by the following Java class: net.sourceforge.pmd.rules.UnusedFormalParameterRule

Example:

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