In a big project maintainability is a big challenge. Visual Studio now has an embedded way to generate code metrics report. When there are >10 binaries present it is always welcome to have a summary report. Such a report can be easily integrated with the daily build and published in different build dashborads,
Details of CodeMetrics itself is a big chapter itself. The following link from MSDN has the basics explained:
metrics.exe (available with PowerTools) we can easily generate XML reports.
Refer to this nice article:
The sole purpose of this article is to generate a short summary report from a generated XML file. Also to convert the individual XML to HTML. For that purpose I have used XSD also from Skinner's blog.
Refer to: http://blogs.msdn.com/b/camerons/archive/2011/02/20/code-metrics-reporting-and-xslt-debugging.aspx
Using the Binary
Mention the input folder name under Folder key in
app.config. Ensure all the generated XML is stored there. Run the exe. The HTML reports will be generated under the
Using the code
In the application we can easily specify the values for a different MI index range. We can mention the input and output folders. All this are driven through the
app.config. The input directory can be passed as a parameter also.
<add key ="Low" value="20"/>
<add key ="Medium" value="50"/>
<add key ="High" value="80"/>
<add key ="Folder" value="CodeMetricsReport"/>
<add key ="OutputXML" value="MetricsSummary.xml"/>
<add key ="OutFolder" value="HTMLReports"/>
CodeMetricsReportGenerator is the primary class. Also it converts the individual reports to
AnalysisCodeMetrics method analyses all the XML files and stores the info in memory.
GenerateMISummaryReport generates the summary report. For this it uses the
Using XML to XSLT transform, we generate the HTML output:
myXslTransform = new XslTransform();
myXslTransform.Transform(outputXML, outputfolder + "\\" + output);
The summary report looks like this:
Points of Interest
The whole idea is to have a track of maintainability index for a large project and showcase easily the data in easily understandable
The next step is to create an MSBuild project which can perform all the tasks like code coverage, code analysis, code metrics,
MSTest, and generate a report.
Pease vote if you find this helpful.