Home > CruiseControl.Net > SubMain’s CodeIt.Right and CruiseControl.NET

SubMain’s CodeIt.Right and CruiseControl.NET

A New Tool

I’m always on the look out for developer tools that can help my development. And if the tools can be integrated with CruiseControl.NET – even better!

Recently I found another static code analysis tool – but one with a difference. The tool is called CodeIt.Right by SubMain (http://submain.com/products/codeit.right.aspx). This performs a static analysis for C# and VB.NET code. The difference is it also offers automatic refactoring – it can fix the problems that it finds!

I got in touch with SubMain and they were happy for me to integrate it with CruiseControl.NET. So, I have put together an integration package to include it.

The Task

As well as integration with the IDE, CodeIt.Right comes with a command line version. This tool goes through and analyses the code and produces an XML report out the other side. So it was a simple matter to add a new task that calls the command-line version.

Rather than stopping there, I’ve tried to add a bit of extra value. First, the task will automatically merge the XML results file. Since this is integrated into the task itself, it will only merge the file if the task is run. I mention this because it is often an issue with the merge task – if it is put in the publishers section it will always merge the file, whether or not the task that is supposed to generate it ran or not.

Second, After the analysis has finished, the task can be configured to scan the results file and fail if any violations over a severity level have occurred.

To call the task is as simple as:

<codeItRight>
  <project>remote.csproj</project>
  <executable>Tools\SubMain\CodeIt.Right\SubMain.CodeItRight.Cmd</executable>
</codeItRight>

Where <project> is the project to analyse (you can also use <solution> for scanning an entire solution) and <executable> is the location of the command line executable. A more complete example is:

<codeItRight>
  <solution>ccnet.sln</solution>
  <executable>Tools\CodeIt.Right\SubMain.CodeItRight.Cmd</executable>
  <crData>ccnet.crdata</crData>
  <failureThreshold>Error</failureThreshold>
  <profile>FullScan</profile>
  <reportingThreshold>Warning</reportingThreshold>
  <timeout>600</timeout>
</codeItRight>

Dashboard Integration

The second part of this integration is to add a dashboard plug-in. Since the report is in XML, it is a simple matter to convert it to a report.

CodeIt.Right already comes with an XSL-T template to generate a report, but since it is part of the product, I wasn’t able to include it in CruiseControl.NET. Instead I have produced a different report. Initially I tried to duplicate the CodeIt.Right report, but my XSL-T skills weren’t up to the challenge :-( So, instead I have produced a CruiseControl.NET specific report.

This report is similar to the main project grid – it displays all the results in a sortable grid:

image

Additionally, the results can be filtered, thus reducing the “noise” in the report.

I also added a summary report, which is included on the main build report:

image

Finally, to round everything off I built a dashboard deployment package, so adding the new reports is as simple as going to the admin console and installing it.

In Conclusion

This was a fairly easy tool to integrate into CruiseControl.NET. The task simply runs the tool and merges the result, with the added benefit of checking the results to fail the build if necessary. The reports were just some simple XSL-T templates, plus a package to make it easy to install!

  1. 11 July, 2010 at 4:25 pm | #1

    Hi Craig,
    I read your very interesting blog on codeItRight & CCNet integration. Alas, it has not gone to plan. Here’s my task :

    C:\builds\src\StructureMap\StructreMap Example\StructureMapExample.sln
    C:\Program Files\SubMain\CodeIt.Right\SubMain.CodeItRight.Cmd
    C:\builds\src\StructureMap\StructreMap Example\StructureMapExample.crdata
    Error
    FullScan
    Warning
    600

    On building ccnet throws an exception:
    Error Message: ThoughtWorks.CruiseControl.Core.CruiseControlException: File not found: C:\Program Files\CruiseControl.NET\server\StructureMap Examples\WorkingDirectory\codeitright.xml
    at ThoughtWorks.CruiseControl.Core.Tasks.FileTaskResult..ctor(FileInfo file, Boolean deleteAfterMerge, IFileSystem fileSystem)
    at ThoughtWorks.CruiseControl.Core.Tasks.CodeItRightTask.Execute(IIntegrationResult result)
    at ThoughtWorks.CruiseControl.Core.Tasks.TaskBase.Run(IIntegrationResult result)
    at ThoughtWorks.CruiseControl.Core.Project.RunTask(ITask task, IIntegrationResult result, Boolean isPublisher)
    at ThoughtWorks.CruiseControl.Core.Project.RunTasks(IIntegrationResult result, IList tasksToRun, Dictionary`2 parameterValues)
    at ThoughtWorks.CruiseControl.Core.Project.Run(IIntegrationResult result)
    at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult result)
    at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request)

    I have set working directory to:
    c:\builds\src\StructureMap.

    Any help or advice you might have that would help me resolve this issue would be much appreciated.

  1. 7 April, 2010 at 4:54 pm | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.