Over-complex code (nested loops, too many conditionals, etc.)
Over-long code (classes, methods, etc.)
Incorrect use of the Flex component lifecycle (commitProperties, etc.)
How to invoke
FlexPMD can currently be invoked from:
The command line
Automator on Mac OS X
TextMate on Mac OS X
How does it work
FlexPMD is delivered with a set of standard rules for Flex/AS development. Each source file that is processed is checked against every rule.
Currently, FlexPMD produces a XML report by default, plus an HTML report when invoked by the Maven site plugin. The XML report can then be consumed by any PMD reports pretty printers (like the PMD hudson plugin).
Types of rules
There are various kinds of rules:
Regular expression based : the rule will process each file line-by-line searching for the specified pattern, and detecting possible violations.
Abstract Synthax Tree (AST) based : the rule will analyze the abstract syntax tree for an ActionScript class to detect possible violations. For example, detecting a deeply nested if-statement.
XPath based : the rule will serialize the AST into an XML stream and then use an XPath expression to to detect possible violations.
The FlexPMD Plugin is a plugin to streamline the development process in regards to FlexPMD violations
It analyses the code and marks the violations inline in the code so that developers can see them as they develop
It allows easy navigation between the list of violations and the associated code
The installation and uninstallation process follow Eclipse standard mechanisms
Help > Install new software
Use the following update site: http://opensource.adobe.com/svn/opensource/flexpmd/plugin/trunk/flex-pmd-eclipse-plugin-site
Select FlexPMD feature and proceed with the installation
Help > Product Details > Installation Details
Configure FlexPMD plugin
Download FlexPMD command line tools ( http://opensource.adobe.com/wiki/display/flexpmd/Downloads )
FlexPMD command line . This is a mandatory field. You have to select the flex-pmd-command-line.jar you want from your hard drive.
FlexPMD custom ruleset . You can leave this field empty, if so a default ruleset will be used.
FlexCPD command line . You have to select the flex-pmd-cpd-command-line.jar you wish from your hard drive.
FlexPMD plugin targets two different type of users with two different goals:
Code review workflow : As a code reviewer I want to be able to audit and review the quality of an entire project or any given functional area in terms of PMD violations.
Development workflow : As a developer I want to see PMD violations in the files I'm working in. If a file changes the violations should be updated immediately.
Code review workflow
Projects that didn’t use FlexPMD from the very beginning
Projects where not all developers use FlexPMD
Code or Application reviews to check the health of the code
Audit specific functional areas
FlexPMD recommendations are displayed in a specific panel and can be sorted attending its relevance or violation type
Code Review workflow
Select any source folder in a project
Right click on it
Select FlexPMD > Run FlexPMD
Projects that start using FlexPMD from the very beginning
Teams that proactively want to promote Collective code and team best practices
FlexPMD recommendations become a first class citizen during development.
During compilation FlexPMD errors can prevent the entire build to succeed and will be displayed in the standard Errors view
FlexPMD execute automatically on every compilation
Right click in a project
Select FlexPMD > Add FlexPMD Nature
Note: If at any point you want to remove the nature you can select FlexPMD > Remove FlexPMD Nature
In the FlexPMD Outline View you'll see the violations in the currently opened editor.
If the arrows button is toggled, whenever the file is saved FlexPMD will be re-executed on it and the Outline will be updated providing always up-to-date information to the developer with very little delay and without having to compile the entire project.
FlexCPD can detect suspect copy/paste sections of code in your project.
Executes on demand
You can execute FlexCPD by right-click in a source folder and select FlexPMD > Find suspect cut & paste.
Creates a list of snippets of duplicated code
You can navigate to the source code file by double clicking on the item