Identifying Duplicated Code with Continuous Integration

As part of my continuous improvement campaign, I have been adding additional processes to our continuous integration server so our team can ensure high code quality.

One issue I have seen is that developers do not take enough time to read each other’s code. This leads to duplicate code that then needs to be maintained in multiple places. Sometimes this is just a one-off, sometimes this is a trend, you need to decide for your project. Practices like code reviews and pair programming can minimize this. There are many tools that can do the mechanical review as well.

The most popular commercial tool is Simian. However, for my project I am using Duplicate Finder, which is open-source software. These tools will scan your source code, not object code, so access to the source code is required. The reports that are generated can help you identify cut & paste programming, or common constructs that can be refactored.

Anthony Steele (the developer of Duplicate Finder) recently integrated changes into the tool to provide an XML output perfect for use with CruiseControl.NET. I’ve created two Xsl files that integrate the Xml reports in both summary form and detail (with file name and line number).

To integrate them into your CruiseControl.NET dashboard

  1. Unzip them both to <cruisecontrol install directory>\webdashboard\xsl
  2. Modify the dashboard.config file in <cruisecontrol install directory>\webdashboard\ as follows
    1. Add the following line <xslFile>xsl\DuplicateReportSummary.xsl</xslFile> to dashboard/plugins/buildPlugins/buildReportBuildPlugin/xslFileNames
    2. Add the following line <xslReportBuildPlugin description="Duplicate Code Report" actionName="DuplicateBuildReport" xslFileName="xsl\DuplicateReport.xsl" /> to dashboard/plugins/buildPlugins/

sha1: 29d5ae55db98db86ebf01d3e8bfd88f15c53b3a4

Leave a Reply

Name *
Email *