DEV Community

Cover image for Code Metrics inside Visual Studio 2022
Emanuele Bartolesi
Emanuele Bartolesi

Posted on

17

Code Metrics inside Visual Studio 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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay