Maintainability Index

[Français][Deutsch]

Measurement of Maintainability Index (MI) with Testwell CMT++ and CMTJava (Complexity Measures Tools)

Testwell CMT++ and Testwell CMTJava support Lines-of-code-metrics, Halsteads Metrics, McCabe Metrics and the Maintainability Index (MI).

MI is a single-number value for estimating the relative maintainability of the code.

Maintainability Index is calculated with certain formulae from lines-of-code measures, McCabe measure and Halstead measures.

The measurement and track maintainability are intended to help reduce or reverse a system's tendency toward "code entropy" or degraded integrity, and to indicate when it becomes cheaper and/or less risky to rewrite the code instead to change it.

There are two variants of Maintainability Index: one that contains comments (MI) and one that does not contain comments (MIwoc). CMT++ and CMTJava calculate them both.
The tools calculate Maintainability Index for functions (and class/struct definitions), for files and for the whole software.

Meanings of the Maintainability Index (MI, with comments) values:

85 and more good maintainability
65-85 moderate maintainability
< 65 difficult to maintain
with really bad pieces of code (big, uncommented, unstructured) the MI value can be even negative

To realize the full benefit of MI, the maintenance environment must allow the rewriting of a module when it becomes measurably unmaintainable. The point of measuring the MI is to identify risk; when unacceptably risky code is identified, it should be rewritten.

Calculation of Maintainability Index

Maintainability Index is calculated on each function/class/struct, on each file and on all files together level.

Actually there are three measures:

  • MIwoc: Maintainability Index without comments
  • MIcw: Maintainability Index comment weight
  • MI: Maintainability Index = MIwoc + MIcw

The general formulae for MI is the following:

        MIwoc = 171 - 5.2 * ln(aveV) -0.23 * aveG -16.2 * ln(aveLOC)

        MIcw = 50 * sin(sqrt(2.4 * perCM))

        MI = MIwoc + MIcw

Where

        aveV = average Halstead Volume (CMT++/CMTJava�s V) per module
        aveG = average extended cyclomatic complexity (CMT++/CMTJava�s v(G) ) per module
        aveLOC = average count of lines (CMT++/CMTJava�s LOCphy) per module
        perCM = average percent of lines of comments per Module

"module" is (in CMT++ case) a C-like function definition, a C++-like member function definition, or a class/struct definition.

further information about Maintainability Index:
Kurt D. Welker, Idaho National Engineering and Environmantal Laboratory: The Software Maintainability Index Revisited (August 2001)
 

further information about Testwell Complexity Measures Tools:
Testwell CMT++/CMTJava


last updated: 24.05.2011

© 2006-2011 Testwell Oy / Verifysoft Technology GmbH
CTA++, CTC++, CMT++ and CMTJava are products of Testwell Oy, Tampere (Finland)
all other trademarks of this site are the property of their respective owners.