[代码质量] Maintainability Index (MI)

转载自: http://www.projectcodemeter.com/cost_estimation/help/GL_maintainability.htm

 

ProjectCodeMeter

Maintainability Index (MI)

[article cited from Wikipedia]

Maintainability Index is a software metric which measures how maintainable (easy to support and change) the source code is. The maintainability index is calculated as a factored formula consisting of Lines Of CodeCyclomatic Complexity and Halstead volume. It is used in several automated software metric tools, including the Microsoft Visual Studio 2010 development environment, which uses a shifted scale (0 to 100) derivative.

Calculation

First we need to measure the following metrics from the source code:

  • V = Halstead Volume
  • G = Cyclomatic Complexity
  • LOC = count of source Lines Of Code (SLOC)
  • CM = percent of lines of Comment (optional)

From these measurements the MI can be calculated:

The original formula:
MI = 171 - 5.2 * ln(V) - 0.23 * (G) - 16.2 * ln(LOC)

The derivative used by SEI is calculated as follows:
MI  = 171 - 5.2 * log2(V) - 0.23 * G - 16.2 * log2 (LOC) + 50 * sin (sqrt(2.4 * CM))

The derivative used by Microsoft Visual Studio (since v2008) is calculated as follows:
MI = MAX(0,(171 - 5.2 * ln(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * ln(Lines of Code))*100 / 171)

In all derivatives of the formula, the most major factor in MI is Lines Of Code, which effec

转载于:https://www.cnblogs.com/0616--ataozhijia/p/11609621.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值