My first blog entry and it’s just a quick one; I’ve been curious about exactly how the code metrics in Visual Studio Team System Development Edition are derived. Here’s an example:

CodeMetrics 

Cyclomatic complexity, depth of inheritance, class coupling and lines of code are all understandable, which has called my attention to the Maintainability Index itself. Is the scale 0-100? How is it derived? What are the thresholds for green, yellow and red? Can I edit the thresholds?

Well, I found nearly all my answers here:

http://blogs.msdn.com/fxcop/archive/2007/11/20/maintainability-index-range-and-meaning.aspx

If you’re in a hurry the answers are:

  • Yes,
  • Maintainability Index = MAX(0,(171 - 5.2 * ln(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * ln(Lines of Code))*100 / 171)  (Just as you suspected, eh?)
  • 100-20 for green, 19-10 for yellow and 9-0 for red,
  • No (but I found that out from somewhere else).

Cheers

Giles