Welcome to EMC Consulting Blogs Sign in | Join | Help

Richard Griffin's Blog

Using the "Simian and Source Monitor" deodorant

Following on from Howards recent post with regards to the use of Simian in VS 2005\3, I thought that I would illustrate how to use a tool for measuring the metrics of a code base especially Cyclomatic complexity. The tool is called source monitor, it has been around for a while and provides support for a variety of different languages. As a code junkie too many metrics can be a hindrance especially when business people find out we can measure the health of the code. However, they provide us with the ability to target our refactoring to areas of the code base that smell bad. Source monitor can be run from the command line or as a NANT build task. Running Source Monitor on completion of code provides feedback on the smell of our code base.

 

For more information about the relationship between Code Coverage and Cyclomatic Complexity check out a post on Howards blog.

 

So, you might be thinking what does this have to do with finding duplicates in your code??? The concept is that we can find duplicate lines of code easier and we can inverse the correlation with high levels of Cyclomatic Complexity. Refactoring can now be targeted at the areas of the code base that really need to be refactored. The way that I have been using the utilities is to first run source monitor on a particular file and find the offending method. Then run Simian to find if there are any duplicate lines of code in the method and refactoring accordingly.

 

To setup Source monitor run the installation and stash accordingly. Setup Visual Studio. Tools-> External tools … click on the Add button. I have created a project level and file level metrics. You can create a solution level project however this can be a little clunky with larger solutions. There are setup guidelines in the help but I provided some screen shots so you can get up and running straight away.

 

Enjoy…


Project Level Configuration

 

 smexternaltools1.gif

 

 

File Level Configuration

 

 smexternaltools2.gif

Published 08 February 2006 18:53 by Anonymous
New Comments to this post are disabled
Powered by Community Server (Personal Edition), by Telligent Systems