FlexMetrics

FlexMetrics is reusing the FlexPMD core engine.
This project consists in giving the metrics any AS3-based projects.

How to invoke it?

At the moment FlexMetrics can be invoked from:

  • The command-line
  • Ant
  • Maven

In command-line:

$ java -jar flex-pmd-metrics-command-line-1.0.jar 
SEVERE: Usage: java com.adobe.ac.pmd.metrics.commandline.FlexMetrics (-s|--sourceDirectory) 
<sourceDirectory> (-o|--outputDirectory) <outputDirectory>


In Ant, you add this to your build.xml:

{code:title=build.xml}
<taskdef name="metrics" classname="com.adobe.ac.pmd.metrics.ant.FlexMetricsAntTask"
       classpath="${flexpmd.libs}/flex-pmd-metrics-ant-task-${flexpmd.version}.jar">
      <classpath>
        <pathelement location="${flexpmd.libs}/flex-pmd-files-${flexpmd.version}.jar" />
        <pathelement location="${flexpmd.libs}/flex-pmd-metrics-${flexpmd.version}.jar" />
        <pathelement location="${flexpmd.libs}/as3-plugin-utils-${flexpmd.version}.jar" />
        <pathelement location="${flexpmd.libs}/as3-parser-${flexpmd.version}.jar" />
        <pathelement location="${flexpmd.libs}/as3-parser-api-${flexpmd.version}.jar" />
		<pathelement location="${flexpmd.libs}/commons-lang-2.4.jar" />
		<pathelement location="${flexpmd.libs}/flex-pmd-ruleset-api-${flexpmd.version}.jar" />
        <pathelement location="${flexpmd.libs}/pmd-4.2.5.jar" />
      	<pathelement location="${flexpmd.libs}/dom4j-1.6.1.jar"/>
      </classpath>
</taskdef> 
	
<target name="metrics">
		<metrics sourcedirectory="${src}" outputfile="${flexpmd.output}/javancss.xml"/>
</target>

In Maven:

pom.xml
            <plugin>
                <groupId>com.adobe.ac</groupId>
                <artifactId>flex-pmd-metrics-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

How to interpret the results

In Hudson, there is a plugin called JavaNCSS which let's the user dive into the FlexMetrics results:

Here is the global trend of the project on metrics:

Here is the result for a single build, highlighting the total and per package numbers: