Understand the complexity and maintainability of your code using Code Metrics in Visual Studio – Maintainability Index

By | January 1, 2016

Welcome back to the the 6th post in the series on understanding code complexity and maintainability.  Over the last few post we have talked about Line Of Code , Class Coupling , Depth of Inheritance  and Cyclomatic Complexity metrics. In this post we will talk about overall Maintainability Index  code metrics.  The maintainability index value measured between an index from 0 to 100. Higher values of this index indicates the better maintainability of code.

The maintainability index calculates in each and every level of code and it bubbling up to project or namespace level with an average value. This index is based on several other metrics that we have already discussed such as

Here is how this calculate :

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

Refer: Maintainability Index Range and Meaning

 

image

 

The Maintainability Index column also includes a set of  icons to give an overall indication of maintainability

low – Low Maintainability  –  ( When Maintainability Index within range of 0- 9)

warning – Moderate Maintainability  –  ( When Maintainability Index within range of 10- 19)

green– High Maintainability  –  ( When Maintainability Index within range of 20- 100)

Code Maintainable Index is one of the important metrics that indicates how easy to maintain your code. When you start writing code for a particular method, the maintainability index starts from 100. with the changes on the code and other metrics factor the index start decreasing

Code Health Indicator

 

Code Health Indicator – A must have visual studio extensions for all app developers

Here is one must use Visual Studio Extension that shows the maintainability index on the fly.

extensionvs

Hope this helps !

6 thoughts on “Understand the complexity and maintainability of your code using Code Metrics in Visual Studio – Maintainability Index

  1. Pingback: #overcommit 1 | abandonedmutex

  2. Pingback: Understand the complexity and maintainability of your code using Code Metrics in Visual Studio

  3. Pingback: How to Understand the complexity and maintainability of the code ? | Abhijit's World of .NET

  4. Pingback: Dew Drop – January 4, 2016 (#2160) | Morning Dew

  5. Pingback: 31 Days …. 31 Visual Studio Tips & Tricks from Daily .NET Tips–January 2016 Links – Abhijit's World of .NET

Comments are closed.