Adobe recently made available Flex PMD a tool that lets you keep track of your code bad practices and helps you by auditing your source directory and displaying common errors 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).
A report is produced describing the violations of a given rule set. FlexPMD includes a rule set that is broad ranging and continually growing. It is also straightforward to create your own new rules.
Originally Flex PMD can be called from: Ant, The Command Line and Maven, but thanks to the FlashDevelop (FD3 from now on ) community a plugin has been made available that lets you use FlexPMD in the FD3 IDE and throws the result right in the Output and Results window of FD3.
1. Download flashdevelopPMD from http://www.kemelyon.com/flashdevelop/flashdevelopPMD.zip
2. Copy PMD.dll into the plugins folder of your FD Application Files.
3. Download flexPMD from Adobe Labs (http://opensource.adobe.com/wiki/displa … /Downloads) and extract to your disk.
Set “PMD jar Location” in Tools -> Settings -> FlexPMD to your “flex-pmd-command-line-1.0.RC3.jar”
Press Ctrl-Shift-A to run FlexPMD in current Project. This version only checks code inside the “src” folder, so you don’t see warnings in your libraries.
To use your own ruleset, set “PMD Ruleset” in Tools -> Settings -> FlexPMD
Thanks again to the FlashDevelop community for spending time in making this useful plugins.