Garren Smith

.Net Coding metric released

. 26 Jan 2010 - Johannesburg

I've finally started my first open source project. In the Agile team I am currently working with, I found I needed a simple metric tool to analyze our code and give some simple code metrics to help the team.

The team was using code coverage as our only metric. Code coverage is a very crude tool to determine the quality of our tests. I wanted some more metrics to help us analyze our code to determine the quality of the code being written. We have as a team set certain standards which must be met for each class being written. Two of these is the lines of code per method and the complexity of the method. I initially looked at Ndepend , which is a fantastic tool, to help us measure these, but Ndepend is more complex then what we required. 

From these humble beginning DrivenMetrics was born. DrivenMetrics is a very simple metrics tool that can analyze an assembly to determine the number of lines in a method and the cyclomatic complexity (number of different branches) of a method.

When I set out to write this library I had some simple goals. I wanted to do TDD, I wanted to use Mono.Cecil to learn a bit about it along with ILasm and I wanted to write a console app with some decent commands like any *nix command line tool. I also wanted a good excuse to use github and get a feel for git and then hopefully eventually be cool like all the other cool kids using github :-)

The library works by using Mono.Cecil to disassemble the a .net assembly and then using Mono.Cecil.Pdb to load all the debugging symbols. The two metrics are then run to analyze the code, the results are then written to an html report. The tool is still very much in its infancy and any help from the greater community would be appreciated. To build the code use rake, I have not used albacore or rake.net as my build library but rather the simple BuildUtils.rb from Jeremy Miller's StoryTeller.

 

I would appreciate any feedback anyone is willing to give. I have a Todo.txt with things I would later like to add to the project. The source code is available on github at: www.github.com/garrensmith/Drivenmetric

 

blog comments powered by Disqus
Fork me on GitHub