Calculation method for code Analysis maintainability index in Visual Studio 2008

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.