Christian
Christian

Reputation: 7852

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:

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

Upvotes: 2

Views: 510

Answers (2)

avandeursen
avandeursen

Reputation: 8668

Not sure if anyone still cares about the answer, but ...

The formula for the Maintainability Index uses the average HV, CC, and LOC. So a possible explanation would be that you removed one or two small classes, which would not be good for the average size, and hence for the MI.

The fact that the MI works with averages is just one of several problems with the Maintainability Index, so you may be better of ignoring it.

Upvotes: 1

Alexander Serebrenik
Alexander Serebrenik

Reputation: 3577

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

Upvotes: 2

Related Questions