Improve code quality with flexpmd

Source: Internet
Author: User
Lai Yong Hao (http://laiyonghao.com) flexpmd is a good thing I recently found, practice down to think for improvement Code Quality is very useful, so we recommend it. Flexpmd is an as3 code review tool that helps improve code quality by finding various defects in the Code through static code analysis. PMD is a tool used to analyze Java code errors and learn code errors through static analysis. The ability to run Java Program Find out many problems of the Java source program. Flexpmd is a "transplant" On Flex developed by the Adobe Professional Service Team. It has developed many coding rules related to as3 to identify many hidden errors. Of course, you can also specify whether or not these rules work, or even define rules yourself.
For more information about flexpmd, see this Mind Map: flexpmd function.

Flexpmd can identify errors that include but are not limited to the following:
1. Unused code (functions, variables, constants, etc)
2. inefficient code (Improper use of dynamic filters, tedious constructor, etc)
3. over-complicated code (nested loops, excessive condition judgments, etc)
4. Too long code (class, method, etc)
5. Improper use of the Flex component collection cycle (commitproperties, etc)
Flex PMD can be used through command lines, Maven, ant, and Automator on Mac OS X. The development team is trying to make it an Eclipse plug-in.

Since I am mainly engaged in development on Windows and Debian Linux, I only want to talk about how to run it from the command line. For other methods, see the document (http://opensource.adobe.com/wiki/display/flexpmd/How+to+invoke+FlexPMD ).
1. download the latest version 1.0.rc4 and decompress it;
2. Enter the extract directory and execute the following command:
Java-jar flex-pmd-command-line-1.0.RC4.jar-S./src/-o.
Here, the-S parameter is used to specify the directory where the as source file is located, and-O is used to specify the output directory of the report. Of course, there are other parameters such as specifying the output report file name, the specific usage can be viewed by executing flex-PMD without parameters. For example, if it runs successfully, we can see that the output directory generates a message "right. XML file. This XML report can be opened by some tools, such as Hudson. But I am a lazy and it is easy to install this plug-in, find a flash application provided by Adobe Online (http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html), the effect is as follows: Principle and other

Similar to most static code analysis tools, the core of PMD is the combination of as3 interpreter and ebnf, which translates the code into an abstract syntax tree (AST). Of course, some rules are completed using regular expressions.
The basic analysis process is as follows: 1. Load rules; 2. Find the as source file in the specified directory; 3. Generate AST; 4. apply rules to each file; 5. generate an XML report.
The rule set of PMD can be expanded, so the technical director or architect of the team can cancel or develop some rules. This tool is very useful to me.

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.