Using checkstyle with bitten

Bitten is a trac plugin for continuous integration which I use for the antdiff project and it does a good job in getting the daily builds organized. One nice feature is the summary for unit tests and code coverage tools (I use corbertura). But what I was missing was a similar summary for my checkstyle reports.

But thanks to XSLT, there is a simple solution: Bitten is able to include test and coverage reports from xml files. And since checkstyle generates a xml file for the results, it was straight-forward to translate the checkstyle xml file to a xml file for bitten. The only problem is that bitten only knows the two mentioned types of reports, so I decided to use the test report. 

And this is the (extremely simple) stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="file">
    <xsl:choose>
      <xsl:when test="count(error) = 0">
        <test status="success" fixture="{@name}" name="No checkstyle errors" file="{@name}" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:for-each select="error">
          <test status="error" fixture="{../@name}" name="{@message}" file="{../@name}" />
        </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="checkstyle">
    <report category="test">
      <xsl:apply-templates/>
    </report>
  </xsl:template>   

</xsl:stylesheet>

Translating the checkstyle xml report using this stylesheet allows you to treat checkstyle results in the same way as unit test failures.

But there is one slight problem: the file names in the checkstyle xml are absolute file names. Hence also the file names in the bitten build summary are absolute. In my setup this means having something like “/tmp/bittenFpQXrh/build_Trunk_22″ in front of the name, which doesn’t look good and it also breaks the link to the source code. The simple solution was to remove the path name from the checkstyle report using the following ant task:

<replace file=“${dir.reports}/checkstyle_report.xml” token=“${basedir}” value=“”/>

Maybe it would be nice not to link the checkstyle results to the source code, but rather to the html reports which give more information about the details of the problem.

Please see on of the antdiff build status pages as an example (click on “Test results” in the checkstyle section).

Haynes catalogue of music

Today I have installed a very first version of a complete relaunch of the old homepage of ‘Music for Oboe’ on Beauty of Code: the Haynes catalogue. ‘Music for Oboe’ is a quite complete listing of compositions for the oboe in the 18th century, which has been collected and published as a book by Bruce Haynes. Several years ago, this data has been made available on music for oboe using a simple Perl application by Peter Wuttke.

Since then, a lot of musicians all over the world contributed to this list, so that Peter and I decided to completely rewrite the application using Ruby on Rails. Well, actually I wrote the application while Peter checked lots and lots of libraries all over Europe to find new works or to validate the information given by others.

Needless to say, there are still a lot of things to do until the final version will go live.

Mapping of diseases

New York Times recently published an article about the work of Dr Butt from Stanford University. He and an increasing number of doctors are starting to group diseases not by their symptoms as in classical medicine, but by their genetic underpinnings.

While I can’t say much about the medical relevance, this work gives rise to an interesting visualisation. Shown is a set of diseases which are related to each other by there genetic similarity. Each disease is represented by a circle with a size proportional to the number of genes involved.