Code Metrics inside Visual Studio 2022


Published on

November 11, 2022

In the last days I was curious about how many lines of code I have written in my last product called Red Origin. I forgot Visual Studio (even the Community Edition) has a built-in feature called Code Metrics.

From the menu "Analyze" -> "Calculate Code Metrics", you can view calculate and see the metrics.

Code Metrics menu

After a few seconds, a new window will open in the bottom area of Visual Studio with a lot of numbers in a table.

Code Metrics numbers

What you can see very quickly are the lines of code metrics. The line of Source code is the number of all lines of code in your project with spaces, blank lines and similar. Lines of executable code are the effective executable lines of code. This number is definitely much smaller than the last one.

There are other metrics present in the report:

  • Maintainability Index: Calculates an index value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability.
  • Cyclomatic Complexity: Measures the structural complexity of the code.
  • Depth of Inheritance: Indicates the number of different classes that inherit from one another, all the way back to the base class.
  • Class Coupling: Measures the coupling to unique classes through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration.

If you want to know more about Code Metrics, you can follow this link for the official documentation.

React, comment and follow on