FlexPMD is a tool that helps to improve code quality by auditing any AS3/Flex source directory and detecting common bad practices, such as:Unused code (functions, variables, constants, etc.)
- Inefficient code (misuse of dynamic filters, heavy constructors, etc.)
- Over-complex code (nested loops, too many conditionals, etc.)
- Over-long code (classes, methods, etc.)
- Incorrect use of the Flex component lifecycle (commitProperties, etc.)
FlexCPD is reusing the JavaCPD engine. This project consists in giving a stream of tokens to the CPD engine using the FlexPMD lexer and let the CPD engine detects duplications in those streams.
Flex Builder IDE PMD Plug-in Configuration:
Download the Eclipse PMD plug-in jar file from below URL and paste into the Flex Builder IDE plugins folder (c:\Program Files\Adobe\Flex Builder 3\plugins) and restart the Flex Builder.
URL: http://opensource.adobe.com/svn/opensource/flexpmd/plugin/trunk/flex-pmd-eclipse-plugin-site/plugins/
Check the FlexPMD plug-in is successfully configured into Flex Builder, through clicking the Window->Preferences->FlexPMD (While clicking the FlexPMD option, show’s configuration fields )
FlexPMD Configuration:
Download the FlexPMD librarys from the following link:
URL:http://opensource.adobe.com/wiki/display/flexpmd/Downloads
Note: Try to download the FlexPMD Zip file from the column (All-in-one-bundle) zip file.
Extract the downloaded zip file into available local drive (Ex: C:\PMD\flex-pmd-all-in-one-bundle-1.1.zip) and extract it. This All-in-One-Bundle contains all supporting jars (Flex PMD, CPD, Rule set, and Code Metrics).
Open the Flex Builder IDE; Click Menu Window->Preferences->FlexPMD
Able to see the below fields, that needs to configure with downloaded PMD Zip (flex-pmd-all-in-one-bundle-1.1.zip) file.
- FlexPMD Command line Installation: Click Browse and open the extracted folder (C:\PMD\flex-pmd-all-in-one-bundle-1.1\) and select the flex-pmd-command-line-1.1.jar.
- FlexPMD custom Ruleset: This field is optional, if any customized Rule set (RuleSet.xml) is defined, we can configure the file path (C:\PMD\customRuleSet.xml) or if it’s blank, the Adobe Flex default Ruleset will be configured automatically.
- Java Command Line: No need to configure, Predefined one.
- FlexCPD Command line Installation: Click Browse and open the extracted folder (C:\PMD\flex-pmd-all-in-one-bundle-1.1\) and select the flex-pmd-cpd-command-line-1.1.jar.
- Minimum tokens: No need to configure, Predefined one.
Steps to FlexPMD Execution:
Right-click any Flex Project & Select the FlexPMD, It shows four sub menus listed below:
- Run FlexPMD – It executes the FlexPMD process and lists the errors in the Flex PMD View.
- Find suspect cut & paste – It executes the FlexCPD process and lists the errors in the CPD View.
- Clean FlexPMD markers – It removes the FlexPMD markers (PMD Error & Warning icons) from the source code.
- Add/Remove FlexPMD Nature – It enable/disable the FlexPMD Nature option. If it’s enabled to our project, while compiling itself, shows the PMD errors (No need to run the FlexPMD separately). As the same, having an option to disable the PMD Nature.
Creating Custom Rule Set:
Adobe Flex provides a separate link to create a custom Ruleset.
URL: http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-ruleset-creator.html
Note: Having an option to generate the FlexPMD Ruleset as xml file in the above URL.
Trouble Shooting Section:
FlexPMD has some issues, So at the time of configuration, Please make sure on below areas.
a. Avoid spaces in the following items:
- Flex Project Name (Eg: CSPortal)
- Project workspace name & Path (Eg: C:\flexworkspace)
- Flex PMD extracted workspace (Eg: C:\PMD\flex-pmd-all-in-one-bundle-1.1)
b. If FlexPMD view is not generated. Please follow the below steps to find issue type.
- Open the Flex Builder in DEBUG mode (Type “FlexBuilder –debug” in command prompt ( Eg: C:\Program Files\Adobe\Flex Builder 3\ ).
- Run the FlexPMD by selecting the Project/Package/file. If any configuration issues or errors, it may listed in the IDE debug console.