PMD (software): Difference between revisions
→Rulesets: +link |
|||
Line 20: | Line 20: | ||
==Copy/Paste Detector (CPD)== |
==Copy/Paste Detector (CPD)== |
||
The '''Copy/Paste Detector (CPD)''' is an add-on to PMD that uses the [[Karp-Rabin|Karp-Rabin string matching algorithm]] to find duplicated code. |
The '''Copy/Paste Detector (CPD)''' is an add-on to PMD that uses the [[Karp-Rabin|Karp-Rabin string matching algorithm]] to find duplicated code. |
||
CPD works with Java, JSP, C, C++, Fortran and PHP code. |
CPD works with Java, [[JSP]], C, C++, [[Fortran]] and PHP code. |
||
==Plugins== |
==Plugins== |
Revision as of 15:28, 4 January 2010
PMD is a static ruleset based Java source code analyzer that identifies potential problems like:
- Possible bugs - Empty try/catch/finally/switch blocks.
- Dead code - Unused local variables, parameters and private methods
- Empty if/while statements
- Overcomplicated expressions - Unnecessary if statements, for loops that could be while loops
- Suboptimal code - wasteful String/StringBuffer usage
- Classes with high Cyclomatic Complexity measurements.
- Duplicate code - Copied/pasted code can mean copied/pasted bugs, and decreases maintainability.
While PMD doesn't officially stand for anything, it has several unofficial names, the most appropriate probably being Programming Mistake Detector.
Typically, PMD errors are not true errors, but rather inefficient code, i.e. the application could still function properly even if they were not corrected.
Rulesets
PMD includes a set of built-in rules and supports the ability to write custom rules. The custom rules can be written in two ways:
1. Using XPath
2. Using Java classes
Copy/Paste Detector (CPD)
The Copy/Paste Detector (CPD) is an add-on to PMD that uses the Karp-Rabin string matching algorithm to find duplicated code. CPD works with Java, JSP, C, C++, Fortran and PHP code.
Plugins
PMD has plugins for JDeveloper, Eclipse, JEdit, JBuilder, Omnicore's CodeGuide, NetBeans/Sun Studio, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, Hudson, Sonar and Emacs.
External links
- Home page at SourceForge.net.
- Book: "PMD Applied". Written by the lead developer, Tom Copeland (http://tomcopeland.blogs.com/).
- Sonar code quality platform uses PMD and CPD