Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt

Use this file to discover all available pages before exploring further.

The Maintainability Index (MI) is a composite score that blends Halstead volume, cyclomatic complexity, and SLOC into a single number representing how maintainable a unit of code is. mehen reports all three commonly used variants.

What mehen emits

KeyTypeVariant
mi.originalfloatOman & Hagemeister, 1992 (raw, can be negative).
mi.visual_studiofloatMicrosoft Visual Studio rescale to 0–100.
mi.seifloatSoftware Engineering Institute (SEI) variant including comment ratio.

Formulas

Original (Oman & Hagemeister, 1992)

MI_original = 171
            − 5.2 · ln(V_avg)
            − 0.23 · CC_avg
            − 16.2 · ln(LOC_avg)
where V_avg, CC_avg, LOC_avg are averages across the unit.

Visual Studio (rescaled 0–100)

Microsoft rescaled MI to a 0–100 range so a single threshold could be applied across files:
MI_VS = max(0, MI_original · 100 / 171)

SEI (with comment ratio)

The SEI variant adds a documentation term:
MI_SEI = 171
       − 5.2 · log₂(V)
       − 0.23 · CC
       − 16.2 · log₂(SLOC)
       + 50 · sin(sqrt(2.4 · CM))
where CM is the ratio of comment lines to total lines.

How to read it

mi.visual_studioInterpretation (Visual Studio default)
20–100Maintainable (green).
10–19Moderately maintainable (yellow).
0–9Hard to maintain (red).
Visual Studio uses these thresholds out of the box.
MI is a composite — it aggregates a few simpler signals. When MI changes, look at the components (Halstead volume, Cyclomatic complexity, SLOC, CLOC) to understand which input moved. The composite is useful for ranking files and tracking trends; it is not the right tool to argue about a specific function in isolation.

References

See also