Maintainability Index

The Software Maintainability Index (MI) is a single-value indicator for the maintainability of a software system. It was proposed by Oman and Hagemeister.

The Maintainability Index is computed by combining four traditional metrics.

It is a weighted composition of the average Halstead Volume per module, the Cyclomatic Complexity, the number of lines of code (LOC) and the comment ratio of the system

The maintainability index value measured between an index from 0 to 100. Higher values of this index indicates the better maintainability of code.

Formula for calculation:

Maintainability Index = MAX(0,(171 – 5.2 * ln(Halstead Volume) –

0.23 * (Cyclomatic Complexity) – 16.2 * ln(Lines of Code))*100 / 171)

Though Maintainability index is helpful but it alone cannot be used to improve the code. Across industry there are few concerns of using this index. Few of them are:

  • Unfortunately different tools compute different results because they simply arbitrarily adjust the formula. Moreover, the complex formula is not easily comprehensible and therefore not all developers understand and interpret it in the same way. There is no clear explanation for the specific derived formula.
  • a developer cannot predict how code changes influence the Maintainability Index.
  • due to the unknown influence of code changes, it is unclear what can be done to improve maintainability
  • Maintainability Index does not provide information about the impact on development activities. A value of 55 does not express which maintainability aspects are affected by a bad value.
  • The Maintainability Index is based on the average per file of, e.g., cyclomatic complexity. However, these metrics follow a power law, and taking the average tends to mask the presence of high-risk parts.