visual-studio-2010code-metricsmaintainability

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.


Solution

  • 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.