Search code examples
visual-studio-2008code-metrics

How come the maintainability index of a project decreases even though cyclomatic complexity, class coupling and lines of code have decreased?


For a C# project of mine the code metrics delta after a refactoring are:

  • Maintability Index: -4
  • Cyclomatic Complexity: -48
  • Depth of Inheritance: 0
  • Class Coupling: -9
  • Lines of Code: -85

How come the Maintainability Index has decreased when the formula is:

MI = MAX(0,(171 - 5.2 * ln(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * ln(Lines of Code))*100 / 171) ?


Solution

  • Possible options: 1) the Halstead volume has increased; 2) you use a MI-variant that takes comments in to account.