Skip to main content

Code Metrics

  • 2 minutes to read

Code Metrics enables you to evaluate code metrics right in the code editor while writing code. By default, a metric appears as a number to the left of a member declaration.

 

CodeMetrics

 

The following metrics are available.

Name Description
Cyclomatic Complexity Cyclomatic complexity is calculated using the number of different code paths in the flow of the program. A program with a complex control flow requires more tests to fully cover the code and is less maintainable.
Line Count The total number of lines that belong to a class member. A very high metric value indicates that a type or method is hard to maintain, and does too much work and should be split up.
Maintenance Complexity Every element of the code (local variable declarations, assignment statements, expressions in for loops, unary operator, etc.) has a weighted value. The maintenance complexity of a member is the total weighted value of all elements contained in or referenced from this member.

Use the Show Metrics options page to specify the shown metric and the way it appears. You can specify the shown metric via the drop-down menu as well. To call the menu, click a metric.

 

MetricsMenu

 

You can enable or disable Code Metrics from either the Show Metrics options page or from the CodeRush Classic toolbar.

EnableCodeMetricsFromToolbar

Note

This product is designed for outdated versions of Visual Studio. Although Visual Studio 2015 is supported, consider using the CodeRush extension with Visual Studio 2015 or higher.