Jan 19, 2007

SourceMonitor and CruiseControl - The Top 15

As a follow up to yesterdays post on SourceMonitor and CruiseControl.NET integration, Eden Ridgway has done some really nice work and posted a few styles sheets to help you create a SourceMonitor Top 15 Summary of worst methods so you can target your refactoring efforts.



Thing good thing is you don't have to use MSBuild as Eden indicates and the steps to get it working are really easy.

  • Then in your NAnt build script simply add a <style /> task after the <exec /> task for SourceMonitor as shown.
<!-- Execute the commands -->
<exec program="${sourcemonitor.executable}" commandline="/C ${sourcemonitor.input}" failonerror="false" />
<style style="SourceMonitorSummaryGeneration.xsl" in="sm_details.xml" out="sm_top15.xml" />
<delete file="${codemetrics.output.dir}\sm_project.smp" failonerror="false" />
The <delete /> task is to clean up the sourcemonitor project file. The file grows over time so leaving it around on a busy build server is probably not a good idea and will just fill up space.

  • Make sure you include the _sm_top15.xml file in your ccnet.config <merge /> task then build the project and you should see some numbers.
What if you don't want a top 15? Maybe you want a top 30? Just edit the SourceMonitorSummaryGeneration.xsl file, find the two lines that look like this
<xsl:when test="position() &lt; 16" />
and change the value 16 to 31.

Also, if you have nesting that goes to 9+ levels, then the summary won't show it. To get this showing you need to change the data-type to "text" in the Nesting Metrics section as shown here:
<xsl:sort select="metrics/metric[@id='M12']" order="descending" data-type="text" />
Finally, you might want to change the labels in the dashboard.config and xsl\sourcemonitor.xsl files to reflect that you are showing a Top 30

Update: Eden has since fixed the stylesheet errors and made it easier to customise the number of items to show. Thanks mate!

3 comments:

  1. Hi Richard. Thank you very much. Great post and thanks for spotting the bug in the summary generation. I have fixed the stylesheet.

    ReplyDelete
  2. Hi ya. I have suggested to include this in the official CC.NET:

    http://jira.public.thoughtworks.org/browse/CCNET-1709

    But they want your permission for using your work. Will you allow CC.NET to use your work ?

    Kind regards

    -Rolf Kristensen

    ReplyDelete
  3. @snakefoot No problem. Go ahead.

    ReplyDelete