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