Book Information


Authors: Tom Copeland
Paperback: 221 pages
Publisher: Centennial Books (November 2005)
Language: English
ImageBook Web Site

 Book Review

About PMD

PMD is a Java Static code analysis tool written by a team of Expert Java programmers. PMD could be used to write better and optimized code by finding potential problems such as unused variables, wasteful resource creation, etc. PMD targets Java Programmers – beginners, hobbyists, Software Developers Team and we say it is for every Java programmer who wishes to employ PMD to test their code for certain rules of consistency and optimization.

It is a simple but very powerful tool with extensive support in the form of IDE Integration, Ant/Maven Tasks, etc. PMD is completely open source and the free download is available at



The general norm with most of the popular Open Source Software is that they are extremely powerful with rich features and definitely needs a good guide to use. Usually the drawback with them is that the documentation is so dull, unlike the excitement found in the software when being used. So the need for a good book is always seen. Thanks to Tom Copeland, PMD scores in this matter. We can simply say that PMD Applied is as good as the software itself is.


Being one of the architects of PMD, Mr. Copeland has given an extensive coverage on PMD in just few hundreds of pages. Unlike other Java books, PMD Applied is not bulky but covers all the aspects of PMD that helps in using it efficiently. In this small book of 220 odd pages, one can get complete working knowledge of PMD, its internals, its best practices and customization, etc - no stone is left unturned.

There are 10 chapters in the book. The first 4 chapters help the reader to setup PMD, how to integrate PMD with popular IDE like Eclipse, JDeveloper, IntelliJ IDEA, etc and also describes usage of Ant/Maven tasks for PMD.

The fifth chapter gives elaborate information about “Copy-Paste Detector”, also known as CPD, a tool which can be well used to detect duplicate code segments and is a part of PMD. It explains why duplicate code is bad and how PMD’s CPD could be used to identify such code segments.

The sixth chapter explains the best practices one should employ while using PMD to test their project. Though there are numerous best practices that could be employed for better usage of PMD, the author concentrated only on few important ones like “Start with rules less prone to false positives”, “Start with small subset of rules”. This chapter is limited on information when compared to the other portion of the book. The author must have added more information on efficient usage of PMD, its rule-sets explaining different scenarios, the way he did successfully in other parts of the book.

The best part of the book starts here with the seventh chapter on writing rules for PMD. PMD is very extendable in the form of user defined rules, custom rule sets. Developers can write their own rules and integrate them into PMD. This chapter explains the two ways in which PMD rules can be written-using XPAth and using Java Language. It starts by explaining the management of Custom rule sets. The next portion of the chapter helps those who wish to write the PMD rules specific to their work environment. The chapter concludes with information on using Symbol table for writing PMD Rules.

The eighth chapter targets those who wish to modify PMD itself. It addresses different issues of customizing PMD like compilation of source code, adding a new report format, adding new language support for CPD. The ninth chapter is the final one on PMD and it presents PMD internals likes the complier concepts on which PMD is built, Data Flow Analysis in PMD, etc. The last chapter gives information on other tools that are similar to PMD. The information includes their activity and some of their features.

Out of the 220 pages, around 90 pages at the end have been dedicated to the PMD rules in the form of Appendix A. Though it is categorized as Appendix, it is really recommended to read at least the description of the rules. This could be very useful for every developer because they help us understand the traps and pitfalls of Java Programming. If a programmer can keep these rules in mind while programming, he shall hardly need any code verification tools in the future.


The best aspect of the book is simple and straightforward presentation. One can clearly notice the author’s best efforts in presenting PMD in a detailed manner. One can really enjoy reading the book, especially the Rules portion of the book, if they are interested in writing optimized programs. PMD and PMD Applied really help developers to write better Java code.

 Table of Contents

    1. Introduction
    2. Installation and Basic Operation
    3. PMD, Ant and Maven
    4. Integrated Development Environment Plugins
    5. Detecting duplicate code
    6. Best Practices
    7. Writing Rules
    8. Customizing PMD
    9. PMD Internals
    10. Similar Open Source Tools




 Overview of Chapters

    1. Introduction

      • What PMD is
      • A brief history about PMD
      • About the book

    1. Installation and Basic Operation

      • Initial Setup of PMD
      • How to run PMD
      • Various Report formats available with PMD
      • Important parameters the PMD tool takes
      • Using Rules and Rule Sets

    1. PMD, Ant and Maven

      • Brief Overview of ANT
      • Using PMD with ANT – Basics
      • PMD with ANT – a working example
      • Other ANT Task options
      • Maven and Ant

    1. Integrated Development Environment Plugins

      • How PMD can be integrated into other tools
      • Integrating PMD with Eclipse
      • Integrating PMD with NetBeans, Java Studio, etc.
      • Integrating PMD with Oracle JDeveloper
      • Integrating PMD with IntelliJ Idea
      • Integrating PMD with jEdit
      • Integrating PMD with JBuilder
      • Integrating PMD with TextPad
      • Integrating PMD with JCreator
      • Integrating PMD with OmniCore CodeGuide

    1. Detecting duplicate code

      • Why duplicating code is bad
      • How to find duplicate code with CPD
      • Running CPD in different ways
      • Internals of CPD

    1. Best Practises

      • Start with small subset of rules
      • Be aware of your team’s likes and dislikes
      • Start with rules less prone to false positives
      • Use NOPMD to block false positives
      • Use a PMD plug-in for your IDE
      • Pass along feedback to the PMD Team

    1. Writing Rules

      • How to build Custom Rules
      • Overview of writing your own Rules
      • How to write rules in XPath
      • Writing rules in Java
      • How to use pluggable warning messages
      • How to embed XPath in Java while writing PMD Rules
      • Using Symbol table while writing rules

    1. Customizing PMD

      • How to compile PMD Source Code
      • How to create our own Report Format
      • How to add support for new language in CPD
      • Adding a custom ruleset short name
      • How to contribute to PMD

    1. PMD Internals

      • Basics: Compiler Concepts
      • PMD and JavaCC and JJTree
      • How symbol table is built
      • Data Flow Analysis subsystem in PMD
      • XPath Integration into PMD

    1. Similar Open Source Tools

      • Source Code analyzers like CheckStyle, JCSC, etc
      • Bytecode analyzers like FindBugs and JLint