##### 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

## Coupling Rules

These are rules which find instances of high or inappropriate coupling between objects and packages.

### CouplingBetweenObjects

Since: PMD 1.04

This rule counts unique attributes, local variables and return types within an object. A number higher than specified threshold can indicate a high degree of coupling.

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

Example:

    import com.Blah;
    import org.Bar;
    import org.Bardo;
    public class Foo {
     private Blah var1;
     private Bar var2;
     //followed by many imports of unique objects
     void ObjectC doWork() {
      Bardo var55;
      ObjectA var44;
      ObjectZ var93;
      return something;
     }
    }

This rule has the following properties:

Name | Default value | Description
threshold | 20 | The unique type reporting threshold

### ExcessiveImports

Since: PMD 1.04

A high number of imports can indicate a high degree of coupling within an object. Rule counts the number of unique imports and reports a violation if the count is above the user defined threshold.

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

Example:

    import blah.blah.Baz;
    import blah.blah.Bif;
    // 18 others from the same package elided
    public class Foo {
     public void doWork() {}
    }

This rule has the following properties:

Name | Default value | Description
minimum | 30 | The import count reporting threshold

### LooseCoupling

Since: PMD 0.7

Avoid using implementation types (i.e., HashSet); use the interface (i.e, Set) instead

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

Example:

    import java.util.*;
    public class Bar {
     // Use List instead
     private ArrayList list = new ArrayList();
     // Use Set instead
     public HashSet getFoo() {
      return new HashSet();
     }
    }