Skip to content

codecop/pmd-rules

Repository files navigation

PMD Rules - Custom PMD Rules

Custom rules for PMD code analysis.

PMD scans Java source code and looks for potential problems. (Read about how it works here.) It comes with more than 200 predefined rules. It's possible to define your own rules; I have done so since 2004. This project contains a mixed set of custom rules for PMD regarding basic bugs, design principles, JUnit test, naming and other rule groups as well as some useful templates to copy from.

The pmd-4.x branch contains some early rules compatible with PMD 4.1 up to PMD 4.3 and its last release is 1.1-pmd4. The pmd-5.x branch contains rules for versions 5.0.5 to 5.8.1 and its last release is 1.2.4-pmd5. PMD 6 is the current one.

Rule Sets

Being lazy, of course I did not write these rule documentations by hand. I had it generated using a Ruby script rule_summary_*.rb that converts PMD's ruleset.xml format into wiki syntax.

Usage

Add the jar containing the rule sets to the PMD classpath, just copy the pmd-rules-x.y.z.jar into PMD's lib folder. Download the latest rules from here. For example the 1.2.4 version is compatible with PMD 5 and PMD 6. For the latest Maven PMD plugin this looks like:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>3.21.2</version>
    <dependencies>
        <!-- comes with PMD 6.55.0 -->
        <dependency>
            <groupId>org.codecop</groupId>
            <artifactId>pmd-rules</artifactId>
            <version>1.2.4-pmd6</version>
        </dependency>
    </dependencies>
</plugin>

You have to add my Mvn2Repo to your Maven repositories to get the releases.

License

New BSD License, see license.txt in repository.

About

Mixed set of PMD rules regarding basic bugs, design principles, junit test, naming etc.

Topics

Resources

License

Stars

Watchers

Forks