Code Metrics – Code Metrics Results Filtering

Windows: Alt, V, M (press several times), Enter

Menu: View | Other Windows | Code Metrics Results

Command: View.CodeMetricsResults

SKU: Premium, Ultimate

Versions: 2008, 2010

Languages: C++ (managed only), C#, VB

Code: vstipTool0135

 

Having explored code metrics in great detail in the previous posts (see the article on Cyclomatic Complexity that started the series here: https://blogs.msdn.com/b/zainnab/archive/2011/05/17/code-metrics-cyclomatic-complexity.aspx) we can now turn our attention to the Code Metrics Results window. One of the first activities you will probably use it for is to calculate the code metrics for your solution:

clip_image001

 

Once metrics have been calculated there are several options available to you to work with the code metrics. Chief among the various actions is filtering. Using a filter, you can narrow down the metric you are interested in. For this example, I’ll choose Class Coupling:

clip_image002

 

Once I choose the metric to filter by then the Min and Max combo boxes are enabled so I can choose my filtering criteria:

clip_image003

 

Here is an example of some data before I apply a filter:

clip_image005

 

And after I apply a filter with a minimum of 3:

clip_image007

 

As you can see the members of DeliveryMethod have been reduced to show only those that match the current criteria. Also, whenever you apply criteria, the last ten filters (at the end of the list, indented) used are available in the Code Metrics window regardless of the project or solution:

clip_image008

 

When Visual Studio is closed the ten most recently used filter criteria are written to the registry at
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\EnterpriseTools\CodeMetrics

 

WARNING: Make changes to the registry at your own risk.

 

A string value called MRUList is created that contains the filter information:

clip_image010

 

There isn’t any way to clear this list that I am aware of so occasionally I’ll just delete the MRUList value from the registry when I want the list to go away. Visual Studio will automatically create a new value once you start making new criteria.