PMD (software)
Encyclopedia
PMD is a static ruleset based Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...

 analyzer that identifies potential problems like:
  • Possible bugs - Empty try/catch/finally/switch blocks.
  • Dead code - Unused local variable
    Local variable
    In computer science, a local variable is a variable that is given local scope. Such a variable is accessible only from the function or block in which it is declared. In programming languages with only two levels of visibility, local variables are contrasted with global variables...

    s, parameter
    Parameter
    Parameter from Ancient Greek παρά also “para” meaning “beside, subsidiary” and μέτρον also “metron” meaning “measure”, can be interpreted in mathematics, logic, linguistics, environmental science and other disciplines....

    s 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
    Cyclomatic complexity
    Cyclomatic complexity is a software metric . It was developed by Thomas J. McCabe, Sr. in 1976 and is used to indicate the complexity of a program. It directly measures the number of linearly independent paths through a program's source code...

     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
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...



2. Using Java classes

Copy/Paste Detector (CPD)

The Copy/Paste Detector (CPD) is an add-on to PMD that uses the Rabin–Karp string search algorithm to find duplicated code
Duplicate code
Duplicate code is a computer programming term for a sequence of source code that occurs more than once, either within a program or across different programs owned or maintained by the same entity. Duplicate code is generally considered undesirable for a number of reasons...

.
CPD works with Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

, JSP
JavaServer Pages
JavaServer Pages is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML, or other document types...

, C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

, Fortran
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

 and PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

 code.

Plugins

PMD has plugins for JDeveloper
JDeveloper
JDeveloper is a freeware IDE supplied by Oracle Corporation. It offers features for development in Java, XML, SQL and PL/SQL, HTML, JavaScript, BPEL and PHP...

, Eclipse, JEdit
JEdit
jEdit is a text editor for programmers, available under the GNU General Public License version 2.0. It is written in Java and runs on any operating system with Java support, including Windows, Linux, Mac OS X, and BSD.-Development:...

, JBuilder
JBuilder
JBuilder is an integrated development environment for the programming language Java, from Borland, and then CodeGear. Codegear was purchased by Embarcadero Technologies in 2008....

, Omnicore's CodeGuide, NetBeans
NetBeans
NetBeans refers to both a platform framework for Java desktop applications, and an integrated development environment for developing with Java, JavaScript, PHP, Python, Groovy, C, C++, Scala, Clojure, and others...

/Sun Studio
Sun Studio (software)
The Oracle Solaris Studio compiler suite is Oracle's flagship software development product for Solaris and Linux. It was formerly known as Sun Studio...

, IntelliJ IDEA
IntelliJ IDEA
IntelliJ IDEA is a commercial Java IDE by JetBrains. It is often simply referred to as "IDEA" or "IntelliJ."-History:The first version of IntelliJ IDEA was released in January 2001, and at the time was the only available Java IDE with advanced code navigation and code refactoring capabilities...

, TextPad
TextPad
TextPad is a text editor for the Microsoft Windows family of operating systems.First released in 1992, this software is currently in its fifth major version...

, Maven
Maven
A maven is a trusted expert in a particular field, who seeks to pass knowledge on to others. The word maven comes from Hebrew, via Yiddish, and means one who understands, based on an accumulation of knowledge.-History:...

, Ant, Gel, JCreator
JCreator
JCreator is a Java IDE created by Xinox Software. Its interface is similar to that of Microsoft's Visual Studio. Because it is programmed entirely in C++, , Xinox Software has asserted that JCreator is faster than competing Java-based Java IDEs.JCreator has three editions:* Lite Edition :...

, Hudson
Hudson (software)
Hudson is a continuous integration tool written in Java, which runs in a servlet container, such as Apache Tomcat or the GlassFish application server. It supports SCM tools including CVS, Subversion, Git and Clearcase and can execute Apache Ant and Apache Maven based projects, as well as arbitrary...

, Jenkins
Jenkins (software)
Jenkins, previously known as Hudson, is an open source continuous integration tool written in Java. The project renamed itself after a dispute with Oracle who claims the right to trademark the Hudson name and has applied for such a trademark as of December 2010...

, Sonar
Sonar (software quality)
Sonar is an open source software quality platform. Sonar uses various static code analysis tools such as Checkstyle, PMD, FindBugs, Clover to extract software metrics, which then can be used to improve software quality.-Features:...

 and Emacs
Emacs
Emacs is a class of text editors, usually characterized by their extensibility. GNU Emacs has over 1,000 commands. It also allows the user to combine these commands into macros to automate work.Development began in the mid-1970s and continues actively...

.

External links

  • Home page at SourceForge.net
    SourceForge
    SourceForge Enterprise Edition is a collaborative revision control and software development management system. It provides a front-end to a range of software development lifecycle services and integrates with a number of free software / open source software applications .While originally itself...

    .
  • CPD at SourceForge.net
    SourceForge
    SourceForge Enterprise Edition is a collaborative revision control and software development management system. It provides a front-end to a range of software development lifecycle services and integrates with a number of free software / open source software applications .While originally itself...

    .
  • Book: "PMD Applied". Written by the lead developer, Tom Copeland (http://tomcopeland.blogs.com/).
  • Sonar (Quality platform) code quality platform uses PMD and CPD
  • Redsauce PMD Parser Small utility that parses PMD output in HTML syntax


The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK