PMD (software)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
PMD
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Written inJava
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemWindows, Linux, macOS
    TypeStatic program analysis tool
    LicenseBSD License, Apache License 2.0, GNU Lesser General Public License[1]

    PMD is an open source static source code analyzer that reports on issues found within application code. PMD includes built-in rule sets and supports the ability to write custom rules. PMD does not report compilation errors, as it only can process well-formed source files. Rather, PMD is designed to detect inefficient code or bad programming habits, which can reduce the performance and maintainability of the program if they accumulate. It can analyze files written in Java, JavaScript, Apex and Visualforce, PLSQL, Apache Velocity, XML, and XSL.

    While PMD does not officially stand for anything,[2] several retro acronyms have been suggested, including for instance Programming Mistake Detector and Project Meets Deadline.[3]

    Features

    [edit | edit source]

    PMD is able to detect flaws or possible flaws in source code, like:

    • 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.

    License

    [edit | edit source]

    PMD is released under a BSDish license while parts of it are under Apache License 2.0 and the LGPL.[1]

    Copy/Paste Detector (CPD)

    [edit | edit source]

    The Copy/Paste Detector (CPD) is an add-on to PMD that uses the Rabin–Karp string search algorithm to find duplicated code. Unlike PMD, CPD works with a broader range of languages including Java, JavaServer Pages (JSP), C, C++, Fortran, PHP, and C# code.

    Plugins

    [edit | edit source]

    PMD has plugins for JDeveloper, Eclipse, jEdit, JBuilder, Omnicore's CodeGuide, NetBeans/Sun Studio, IntelliJ IDEA, TextPad, Maven, Ant, Gradle, Gel, JCreator, Hudson, Jenkins, SonarQube, Visual Studio Code and Emacs.[4] There is also a CLI version.

    See also

    [edit | edit source]

    References

    [edit | edit source]
    1. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).

    Further reading

    [edit | edit source]
    [edit | edit source]