Halstead Maintainability Index is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Halstead Maintainability Index
API ID: HalsteadMaintainIdxLanguages: Any
Targets: Files, Functions
Original Halstead Maintainability Index
This metric measures how easy it is to maintain and change code. It is calculated using the Halstead Volume , Strict Cyclomatic Complexity, Lines of Code (SLOC) and Comment to Code Ratio. (Coleman, Don, Dan Ash, Bruce Lowther, and Paul Oman. "Using Metrics to Evaluate Software System Maintainability." IEEE Computer, vol. 27, no. 8, 1994, pp. 44-49.)
The higher the metric the easier the code is to maintain.
Maintainability Index = 171
- 5.2 * ln(HalsteadVol)
- 0.23 * CyclomaticStrict
- 16.2 * ln(CountLineCode)
+ 50 * sqrt(2.46 * RatioCommentToCode)
Treemap with red functions being the hardest to maintain