Learning Resources for Software Engineering Students »
Author: Xiao Pu
Rules in PMD represent patterns in code. PMD is supposed to check these rules(patterns) and signal violations to programmers. For example, the
OverrideBothEqualsAndHashcode rule requires programmers to override both
public boolean Object.equals(Object other), and
public int Object.hashCode(), or override neither.
PMD supports checking rules for the following languages.
PMD doesn't support checking rules for the following languages. Only Copy/Paste Detector (CPD) is supported for them.
Limitations are almost the same as CheckStyle.
You can configure PMD to only include the rules that your want (see How to make a new rule set).
PMD supports suppressing warnings in four ways:
The details are described here.
PMD can be launched by using command line with various arguments. For details, please refer to Running PMD via command line.
PMD can be integrated with most of IDEs, inlcuding BlueJ, CodeGuide, Eclipse, eclipse-pmd, Emacs, Gel, IntelliJ IDEA, IntelliJ IDEA - QAPlug, JBuilder, JCreator, JDeveloper, JEdit, Maven, Maven 2, NetBeans, TextPad, WebLOgic Workshop 8.1.x. For instruction to integrate with those IDEs, please refer to PMD integrations.
There is not pre-defined rules set. You need to define your rule sets by yourself.
PMD has organised rules into different categories. For example, the rules for Java has been categorised into 26 sections, which will help you quickly find the rules that you want.
PMD use JavaCC to parse your code to a AST(Abstract Syntax Tree) and visited it recursively (more details). Thus, one of the requirements for PMD to work is that the code must be in valid Java syntax. You can view the syntax tree by using bin/designer.bat