Code Metrics

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:


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:

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).



Comments (0)