
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:
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.

Installation
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”

Usage
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.

Yeah Ryan it’s pretty useful and helps you to improve your code, and the fact that you can write your own rules makes it even better.
I’m getting some weird errors out of it – like it insists on throwing errors for my package names on the basis that they have capitol letters, but they certainly do not. It also only wants you to use addChild in an “addChildren()” method – which seems a little excessive.
Yes it appears to have some bugs but some of them are already reported like “The copyright header is missing in this file” and ” A package name should be lower case. Detects when a package definition contains upper case characters” guess we have to wait until Adobe fixes those bugs or write our own sets of rules. We can fill a bug at https://bugs.adobe.com/jira/browse/FLEXPMD or ask some specific question at http://forums.adobe.com/community/opensource/flexpmd?view=discussions&start=0
That’s great news. Will install, test and blog my results – doubtless FD3 will come out looking better than my code…
Dude, how can I make PMD use code not in src folder, or where does PMD search for src folder
The current version of Flex PMD will only check your src folder but You can write your own rulesets to add more folders or rules here’s how to doit if you’re using Flash Develop:
Usage: 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
Thank you , but u still didnt do me any favour bro. that much i knew. can u atleast tell me where PMD search for this “src” folder.
Sure, The Plugin for Flash Develop wil search in Your project’s folder, I haven’t tested on Eclipse yet, only Flash Develop and command prompt. On command prompt You can select the folder that you want FlexPMD to “scan” like this: java -Xmx256m -jar “C:/FlexPMD/flex-pmd-command-line-1.0.jar” -s “C:/THE/DIRECTORY/YOU/WANT/TO/SCAN/” -o . -r “C:/FlexPMD/pmd.xml”
Hope this helps.
12:27 pm
This is sweet. Just installed it, and I’m going to recommend it to the rest of my team. Thanks for the post!