##### Overview

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

##### For example

- Run PMD on a Sourceforge project

##### Rule Sets

- Index
- 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 PMD
- Project Info
- Project Reports
- Development Process

## Import Statement Rules

These rules deal with different problems that can occur with a class' import statements.

### DuplicateImports

Avoid duplicate import statements.

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

Here's an example of code that would trigger this rule:

    import java.lang.String;
    import java.lang.*;
    public class Foo {}

### DontImportJavaLang

Avoid importing anything from the package 'java.lang'. These classes are automatically imported (JLS 7.5.3).

This rule is defined by the following XPath expression:

    //ImportDeclaration
     [starts-with(Name/@Image, 'java.lang')]
     [not(starts-with(Name/@Image, 'java.lang.ref'))]
     [not(starts-with(Name/@Image, 'java.lang.reflect'))]
     [not(starts-with(Name/@Image, 'java.lang.annotation'))]
     [not(starts-with(Name/@Image, 'java.lang.instrument'))]
     [not(starts-with(Name/@Image, 'java.lang.management'))]

Here's an example of code that would trigger this rule:

    // this is bad
    import java.lang.String;
    public class Foo {}

    // --- in another source code file...

    // this is bad
    import java.lang.*;

    public class Foo {}

### UnusedImports

Avoid unused import statements.

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

Here's an example of code that would trigger this rule:

    // this is bad
    import java.io.File;
    public class Foo {}

### ImportFromSamePackage

No need to import a type that's in the same package.

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

Here's an example of code that would trigger this rule:

     package foo;
     import foo.Buz; // no need for this
     import foo.*; // or this
     public class Bar{}