Introduction to PMD, usage, application in the project

Source: Internet
Author: User

about PMD

PMD is scanning Java source code and looking for potential problems: a null-and-void capture block (catch blocks) never used parameter NULL if declaration duplicate import declaration never used private method isolation Class short or long type variable and method name

PMD has plug-ins with the following software: JEdit, JBuilder, Netbeans/sun one Studio, IntelliJ idea, TextPad, Maven, Ant, Eclipse, Gel, Emacs

1, the meaning of PMD

Frankly speaking, we don't really know what the true meaning of PMD is (we just think the three letters are Better Together). However, we propose several explanations for the calculation industry for reference.

Pmd:pretty (almost omnipotent) Project Mess detector (Project fault detector) project Monitoring directives (project Monitor) Protein Mutant Database (gene mutation data base) project meets deadline (project expiration) programming mistake R (program error detector) Pounds Mistakes Dead (complete error correction) PMD meaning Discovery (explore PMD meaning)

2. PMD operating mechanism

PMD checks the source code according to the rules and produces a report. As follows: There is a filename and ruleset incoming PMD PMD passes the InputStream of the file to the parser generated by javacc-to obtain a reference RuleS to the abstract Syntax tree (AST) from the parser Each rule in et iterates through the AST and examines the error report contents including ruleviolations and code/files that conform to XML, HTML, or other formats

PMD Usage
1. To use PMD, first download the PMD plug-in, at Eclipes Point Help, select Softwareupdates, then choose Available Software and then point to the right add site will http:// pmd.sourceforge.net/eclipse/-Input,-click http://pmd.sourceforge.net/eclipse/will appear PMD for Eclipse2 and PMD for Eclipse 3 Select one of the PMD for ECLIPSE2 and then click Install, so the configuration is OK.

2. But the specification is too strict, because we can only adopt some of its specifications relative to the public, but we have to go to http://www.springside.org.cn/download.php Load a springside3.0.4.all.in.one, and then in the Project-> property->PMD, the SPRINGSIDE.0.4.ALL.IN.ONE/TOOLS/CONFIGURES/PMD/ Springside3_ruleset.xml is imported into the project. After you change the settings, you need to re export the file and clear the original label and check again.

3. After these are all done, if you find that he can not write the code in time to give prompt, it is you are pouring into the springside.0.4.all.in.one/tools/configures/pmd/springside3_ Ruleset.xml, then you can select the Enable PMD and include derived files two.

4. After these are matched, after you select the project right click, select PMD has several options:

Generate reports: Generate reports, generated in the reports of your engineering directory

Clear violation Reviews

Find suspect cut and Paste.: is a file that checks for the suffix of the designation. such as java,jsp, etc.

Check-code with PMD is the checking code.

After the above steps will be in the project static testing of each of your lines of code, if there is a failure to meet the requirements of the warning.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.