ccnetwarningstats.png

On the project I’m currently working on we are struggling to have all of public classes and methods documented. Since we haven’t been very disciplined doing that, we still have around 400 warnings related to code comments, which can be problematic since some more important warnings could be overlooked in this mass.

Since we already have CC.Net Statistics set up on our build server, I decided to use it to track compiler warnings so that we make sure their number not increasing with new builds. So here are instructions on how to set it up on your CC.Net build server.

(NOTE: we are using the old version of CC.Net Statistics which came before the codeplex project, so I’m not sure the same procedure applies to the new MSI-based version. I couldn’t make the new version run on our build server, I think it is probably because our CC.Net was installed manually and not using the MSI installation).

Okey, so the first thing to do is to tell CC.Net that your project should collect statistics about compiler warnings. Open your CC.Net project configuration file and find the <publishers> tag for the project. Insert the following XML code inside the <publishers> tag (it should be after the any <merge> publisher and before any <xmllogger> publishers):

<statistics> <statisticList> <statistic name=’Compiler Warnings’ xpath=’count(//*[contains (text(),"warning CS")])’/> </statisticList> </statistics>

If you already have the statistics publisher, just add the warning statistics line.

After saving the file, CC.Net should reload the configuration and start recording the statistics for the future builds. Now we have to add graphs for compiler warnings in CC.Net WebDashboard. Open the webdashboard\javascript\GraphConfiguration.js file in the text editor and find “var _recentGraphConfigurations” array. There you have to defined a new “recent graph” by adding the following lines:

//Compiler
{
   graphName: "Compiler",
   dataSource: _recentStatistics,
   numXTicks: _numberRecentGraphXTicks,
   series: [
      { name: "Warnings", attributeName: "Compiler Warnings", color: "green" }
   ]
},

You can choose your own title and color, off course.

To include warnings graph in the summary graphs page, first an function calculating the average warnings has to be added to the “var _summaryConfiguration” array:


//Compiler
compilerWarnings: function(successfulBuilds, failedBuilds) { return average(successfulBuilds, "Compiler Warnings") },

Now we have to add the summary graph to the “var _historicGraphConfigurations” array:


//Compiler        
{
   graphName: "Compiler",
   dataSource: _summarisedStatistics,
   numXTicks: _numberHistoricGraphXTicks,
   series: [
      { name: "Average Warnings", attributeName: "compilerWarnings", color: "green" }
   ]
},

After saving the file, don’t forget to restart the WebDashboard application in IIS (the easiest way is just to “touch” its Web.config file). After the next build, you should be able to see new graphs on your project statistics page.