Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Visual Studios calculate the Maintainability Index?

I have been browsing through the posts and the MSDN, but I am not seeing how the Maintainability Index is created. Only what the good and bad values are.

http://msdn.microsoft.com/en-us/library/bb385914.aspx

Does anyone know? Can we get a reference or explination as to what they are using?

I am interested in what is defined as easy to maintain code. Also more detail on the other metrics would be welcome, but as extra credit. The explination for the other metrics is much more understandable.

like image 501
JPK Avatar asked Feb 21 '14 13:02

JPK


2 Answers

There is an explanation on the blog of their Code Analysis Team.

The actual formula for it is:

Maintainability Index = MAX(0,(171 - 5.2 * ln(Halstead Volume) 
    - 0.23 * (Cyclomatic Complexity) 
    - 16.2 * ln(Lines of Code))*100 / 171)

But don't just listen to me, go get the full read there.

like image 87
user3352250 Avatar answered Oct 11 '22 07:10

user3352250


The history of the maintainability index goes back to 1992, and was included in Visual Studio in 2007.

Since then, several papers have appeared critically discussing the index, the coefficient, the metrics it is composed of, and the difficulty of using it in practice.

For a summary, you can checkout my blog post "Think Twice Before Using the Maintainability Index."

like image 34
avandeursen Avatar answered Oct 11 '22 07:10

avandeursen