QALab Generating Charts

Once you have a qalab.xml file, it is possible to extract some useful information. Feel free to develop your own mechanism, However, the most potent way to analyse it is probably via a chart. There are 2 types of charts:

  1. Summary chart: This is a chart for the project as a whole.
  2. File Chart: This generates a chart for each file in the qalab.xml

Both charts are time-series charts (x-axis is a date). You can also select:

  • Select the type of statistics to display (checkstyle|findbugs|pmd|pmd-cpd|simian).
  • Whether you want a rolling average (over n runs) in order to smooth the trend.

At the moment, it seems that jFreeChart 1.0.1 does not seem to work with Maven 1.x but it is ok with ant. It is your choice, we show both examples below.

Checkstyle Charts

Here is the ant call, we have not described how or where you generate the checkstyle xml file:

<taskdef name="buildchart" classname="net.objectlab.qalab.ant.BuildStatChartTask">
  <classpath>
   <pathelement location="${lib}/qalab-1.0.jar" /> 
   <pathelement location="${lib}/xercesImpl-2.6.2.jar" /> 
   <pathelement location="${lib}/jcommon-1.0.5.jar" /> 
   <pathelement location="${lib}/jfreechart-1.0.2.jar" /> 
   <pathelement location="${lib}/log4j.jar" /> 
  </classpath>
</taskdef>

<buildchart inputFile="qalab.xml" 
            toDir="${doc}/style/charts" 
            movingAverage="10" 
            width="500" height="333" 
            summaryOnly="false" 
            summaryType="checkstyle,pmd" 
            type="checkstyle" 
            quiet="true"/>
        
ParameterMandatoryDescription
inputFileYesThe input file, in this case the qalab.xml, the consolidated statistics file.
toDirYesThe output directory as there will be multiple charts (one per file in qalabs.xml).
movingAverageYesif value > 0, it will draw a moving average based of the given number of runs. In this example it will be based on the last 10 runs.

The value put in movingaverage is the number of points used to calculate an average. say we have;
  • t1 = 10
  • t2 = 20
  • t3 = 15
  • t4 = 3
eg, "2" will take the LAST 2 points and average them out:
  • average on t1 has no value
  • average on t2 is (10 + 20) /2
  • average on t3 is (20+15)/2
  • average on t4 is (15+3)/2
Setting it to 3 would take 3 points into account:
  • average on t1 has no value
  • average on t2 has no value
  • average on t3 is (10+20+15)/3
  • average on t4 is (20+15+3)/3
Setting to 1 is not really a good value as it would always be the same value as the current point. This mechanism basically "smoothes" any spike and drop.
widthYeschart width in pixels.
heightYeschart height in pixels.
summaryOnlyYesif 'true' or 'yes', only draw one chart for the summary section in qalab.xml.
summaryTypeYesselect the types that one wants to appear on the summary chart.
typeYesany combination of 'checkstyle','pmd','pmd-cpd', 'simian','findbugs','cobertura-branch', 'cobertura-line' comma-separated. The chart will contain one serie (line) for each style; eg 'checkstyle' will only display checkstyle. 'checkstyle,pmd' will display both checkstyle and pmd.
quietYes(default true), if false logs debug information on the console.

the summary chart will be called:

  • summary.png for the summary chart
  • full_path_File.java.png for a file

PMD Charts

Here is the ant call:

 <taskdef name="buildchart"
  classname="net.objectlab.qalab.ant.BuildStatChartTask">
   <classpath>
    <pathelement location="${lib}/qalab-1.0.jar" />
    <pathelement location="${lib}/jcommon-1.0.5.jar" />
    <pathelement location="${lib}/jfreechart-1.0.2.jar" />
    <pathelement location="${lib}/log4j.jar" />
   </classpath>
 </taskdef>

 <buildchart inputFile="qalab.xml"
   toDir="${doc}/style/charts"
   movingAverage="10"
   width="500" height="333"
   summaryOnly="false"
   summaryType="pmd"
   type="pmd"
   quiet="true"/>
        

Stylesheet to create a wrapper HTML

We have also created an XSL stylesheet to generate an html file that displays all these charts. Here is how it is called from ant, in this instance for 'checkstyle'. Please ensure that the TIME is defined using the same pattern as below!

<tstamp>
  <format property="TIME" pattern="yyyy-MM-dd" offset="-48" unit="hour"/>
</tstamp>
<style in="qalab.xml" out="hist.html" style="qalab-chart-html.xsl">
  <param name="targetdir" expression="target/docs/qalab"/>
  <param name="type" expression="checkstyle"/>
  <param name="offset" expression="${TIME}"/>
</style>
        

This then generates a series of html files in a frame like this: