Translated from:
Http://blogs.msdn.com/fxcop/archive/2007/11/20/maintainability-index-range-and-meaning.aspx
The first calculation of the maintainability index is this (from Carnegie Mellon University's research, but given that the calculations do not include annotations, the calculation of Holst is modified):
maintainability index = 171-5.2 * LN (HOLST)-0.23 * (cyclomatic complexity)-16.2 * LN (number of lines of code)
This can be calculated as a value of 171 to negative infinity. When the maintainability index tends to 0 o'clock, the code is difficult to maintain, so there is not much difference between 0 and minus infinity.
To make this metric look clearer, we take all negative numbers as 0 and the exponential range from 0 to 100, transforming the formula to:
Maintainability index = MAX (0, (171-5.2 * LN (HOLST)-0.23 * (cyclomatic complexity)-16.2 * LN (lines of code)) *100/171)
On the basis of adjusting the formula, consider dividing different thresholds: 0-9 = Red 10-19 = Yellow 20-100 = Green