Friday, September 04, 2009

FlexPMD exception

Adobe Technical Services just launched a code coverage tool called FlexPMD to find the worst coding practices in your Flex code spread. FlexPMD runs through code patterns in all referenced mxml and ActionScript files of your project and compares it with the "FlexPMD ruleset" to flag it as either an info, warning or error.


FlexPMD runs in various configuration - command line, ant, maven,I chose the ant version of FlexPMD


I set up my ant build.xml just similar to the one in http://opensource.adobe.com/wiki/display/flexpmd/How+to+invoke+FlexPMD


Modify ant.bat

set ANT_OPTS=-Xms128m -Xmx512m

Create the rules: go to FlexPMD ruleset creator on http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-ruleset-creator.html and press export (Looks like the boys at adobe set the browser in full screen - You may not be able export, so pres F11 fullscreen - if you still don't see it use a larger resolution or use tab key/space to navigate/select).


This is a workaround for a FlexPMD Known issue (Quoting from the flexPMD wiki http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD)


* Stack traces can be thrown during parsing. They are caught though during analyzing the code base, and hence fails over



[flexPmd] INFO: rule adobe.ac.pmd.rules.maintanability.forbiddentypes.UseGenericType computed in 188ms

BUILD FAILED
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.adobe.ac.pmd.files.impl.AbstractFlexFile.getLineAt(AbstractFlexFi
le.java:178)
at com.adobe.ac.pmd.rules.style.CopyrightMissingRule.findViolationsInCur
rentFile(CopyrightMissingRule.java:65)



The error occurred at file com.adobe.ac.pmd.rules.style.CopyrightMissingRule, i'll be debugging to find out why we got a IndexOutOfBoundsException later on.. Sure its an exception to be handled
but now i dont care of copyrights missing. I remove that rule by deleting to for class="com.adobe.ac.pmd.rules.style.CopyrightMissingRule"


Eventually this worked


use PMD violations (http://opensource.adobe.com/svn/opensource/flexpmd/bin/flex-pmd-violations-viewer.html) viewer to check your results