Ted Patrick - Demos & MAX @ Adobe Systems


Note: This is the personal blog of Ted Patrick. The opinions and statements voiced here are my own.



FlexPMD - Finding worst practices in your projects

DIGG IT!     19 Comments Published Wednesday, September 02, 2009 at 7:40 AM .

A new project at Adobe was released yesterday as Open Source Software, FlexPMD. The project runs a set of extensible rules over your AS3 or Flex source to detect bad coding practices and raise awareness that these issues exist. This is especially important for team development projects where code is being edited in mass and quality practices become essential.



The rule set within FlexPMD is extensible and you should customize rules to fit your project. If you want to detect undocumented methods or enforce naming conventions, feel free to write a rule for that, and better still share the rule (FlexPMD is open source).

Here is the FlexPMD Ruleset Creator. It is a Flex app that lets you export a set of rules custom to your app needs.

Once you have run FlexPMD against your project, you can load the output into the PMD Violations viewer to see all the issues.

FlexPMD also supports Hudson integration so with every build tests are run automatically and the team has a scorecard of quality throughout development. Seeing projects from this point of view really changes your perspective. I know on the Adobe Professional Services team FlexPMD has enabled teams to see deep within very large projects.

My favorite feature of FlexPMD is flagging unused code. It is so easy to create a variable or method that goes unused. Detecting these within your project is hard and deleting a method always feels like a risk unless you really know it is unused. Having a tool to flag these is great and better still it gives me the confidence to delete methods and properties with impunity.

I would like to thank Xavier Agnetti and the Adobe Professional Services team for making FlexPMD possible. Also there are a vast number of people who were involved in making this project open source within Adobe. It is really great seeing so many developers explore their projects from a quality perspective today over Twitter. I know that FlexPMD will have a long term impact on the quality of apps on the platform and help take things to the next level.

Cheers,

ted :)

19 Responses to “FlexPMD - Finding worst practices in your projects”

  1. # Blogger RJ

    I'm really excited about this, Ted. Is there a good tutorial out there for how to install it and run it against my code? Does it require a server?  

  2. # Blogger Ted Patrick

    RJ, There isn't a good tutorial out there yet. FlexPMD is java based and doesn't require a server at all. There are ANT scripts, Command line, and MAC Automator options for using it all prebuilt.

    The current options allow for the widest possible integration in projects of all shapes and sizes.

    I would think that the command line would be the best option for most folks.

    Ted :)  

  3. # Blogger jeremy

    Aw man, this is fantastic - as you said, I'm totally stoked about finding unused code.  

  4. # Blogger Fréderic Cox

    We are working with a team of relatively new Flex developers. I handed them the coding standards a few weeks ago and this tool will certainly help them (and me) a lot. Awesome tool can't wait to try it out!  

  5. # Anonymous kris

    Very excited to start using this!

    Did run into issues though using this via ANT in Eclipse (maybe not yet supported?). Whats the proper venue to post/ask questions? The FlexPMD forum wasn't working for me...  

  6. # Anonymous Mike K

    The command line tool zip file seems to be missing the all_flex.xml file...  

  7. # Blogger Ron

    What versions of flex is this compatible with? For instance I have a large project I work on that is currently stuck on Flex 2.0.1  

  8. # Blogger Erwin Verdonk

    Mike, the all_flex.xml file is included in FlexPMD from RC3. However you can always create your own rulset XML file with the FlexPMD Ruleset Creator.  

  9. # Anonymous coutant

    AT least a code check style for AS3/Flex. Nice.

    Looking at the 'How to invoque FlexPMD' page : http://opensource.adobe.com/wiki/display/flexpmd/How+to+invoke+FlexPMD.

    The maven-style does mention to point to repository : http://opensource.adobe.com/svn/opensource/flexpmd/trunk/maven-repository.

    At the moment that repository does not exist...

    As an alternative, I could checkout the source code http://opensource.adobe.com/svn/opensource/flexpmd/trunk. But could not build the artefacts.  

  10. # Blogger Geirr

    Here is a quick and dirty explanation on how to use the command line version.
    After you download the archive, unzip it to c:\Flex-PMD

    Then in your sourcecode main directory(same as the src directory is in)

    Create a directory called pmd

    Type the following command
    java -Xmx256m -jar c:\flex-pmd\flex-pmd-command-line-1.0.RC3.jar -s ./src/ -o ./pmd/ -r C:\flex-pmd\pmd.xml

    the c:\flex-pmd\pmd.xml file is generated by the ruleset creatior and you have to download it to your local drive.

    You can find the ruleset creator at
    http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-ruleset-creator.html

    export the ruleset and save it..

    Rgds
    Geirr
    Twitter: gwinnem  

  11. # Anonymous Norbert Kopcsek

    Hi Ted, integrate it in Hudson today and works great.  

  12. # Anonymous Philipp

    hi ted.
    i was really excited when i read about flexpmd ... but had problems getting it to run in eclipse (ant).
    maybe you can shed some light on how exactly the build-file should look like ...!?

    i'm getting an error:

    Buildfile: D:\DEVELOP\apdev\build.xml
    flexPmdWithDefaultRuleset:

    BUILD FAILED
    D:\DEVELOP\apdev\build.xml:39: java.lang.NoClassDefFoundError: org/codehaus/plexus/util/IOUtil


    help would be appreciated :)
    phil  

  13. # Anonymous Sergiu

    Hi Philip,

    There is a missing reference to plexus-utils-1.0.2.jar lib in taskdef for ant, it should look like:

    < classpath >
    ...
    < pathelement location="${flexpmd.dir}/lib/plexus-utils-1.0.2.jar"/ >
    < /classpath>

    Regards,
    Sergiu  

  14. # Blogger francesca

    I am getting the same error as Phil

    java.lang.NoClassDefFoundError: org/codehaus/plexus/util/IOUtil

    I am on a mac and running at 1.7.1

    Any help to get this going would appreciated.

    thanks  

  15. # Blogger Xavier Agnetti

    There used to be a mistake in the documentation. Plexus jar was missing.

    Please refer to one of the previous comment of this post or go to
    http://opensource.adobe.com/wiki/display/flexpmd/How+to+invoke+FlexPMD#HowtoinvokeFlexPMD-FromAnt  

  16. # Anonymous coutant

    I will respond to comment #9 mentionning the Maven build.

    The 'How to invoque FlexPMD' page has been upgrated : http://opensource.adobe.com/wiki/display/flexpmd/How+to+invoke+FlexPMD

    Url repository is now : http://opensource.adobe.com/svn/opensource/flexpmd/maven-repository/release/

    But there is still an error in documentation. You need to switch to 'true' so as to enable release artifacts :

    <pluginRepositories&gth;
    <pluginRepository&gth;
    <id>flexpmd.opensource.adobe</id>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    <name>FlexPMD repository on opensource.adobe.com</name>
    <url>http://opensource.adobe.com/svn/opensource/flexpmd/maven-repository/release/</url>
    </pluginRepository>
    </pluginRepositories>  

  17. # Blogger Diego Guebel

    Fantastic news, I was looking for such a tool for AS3 for while.

    Thanks for sharing this project

    Cheers,
    Diego  

  18. # Blogger Harry B. Garland

    I'm confused about how to use this. There seems to be a lot of JAR files. I don't see anything that looks like a "setup.exe". And I'm not finding any documentation that describes the step by step process for how to work this thing.  

  19. # Blogger chesne

    Hi Ted,
    How can i add my exported rules from the rulset creator to my automator.

    I use PMD from Automator on my mac.

    thanks.  

Post a Comment

Where to find me:

Ted on Twitter - @AdobeTed
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe


Latest

Lists

Links

Jobs

Flex Jobs
city, state, zip

Archives