Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions docs/code-quality/how-to-generate-code-metrics-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can generate code metrics data in three ways:

- By enabling [.NET code-quality analyzers](#net-code-quality-analyzers-code-metrics-rules) and enabling the four code metrics (maintainability) rules it contains.

- By choosing the [**Analyze** > **Calculate Code Metrics**](#calculate-code-metrics-menu-command) menu command within Visual Studio.
- By choosing the command or button to analyze code metrics in Visual Studio. Results are displayed in the Code Metrics window.

- From the [command line](#command-line-code-metrics) for C# and Visual Basic projects.

Expand Down Expand Up @@ -60,10 +60,29 @@ You can configure the thresholds at which the code metrics rules fire.
</ItemGroup>
```

## Calculate Code Metrics menu command
## Calculate Code Metrics

Generate code metrics for one or all of your open projects in the IDE by using the **Analyze** > **Calculate Code Metrics** menu.
Generate code metrics for one or all of your open projects in the IDE by using the Code Metrics window.

::: moniker range="visualstudio"
### Generate code metrics for a solution or project

You can generate code metrics results for an entire solution or project using the following method:

1. In **Solution Explorer**, set the scope of results to either a solution or project by selecting either the solution or project.

1. From the menu bar, select **View** > **Other Windows** > **Code Metrics**.

The Code Metrics Results window opens.

1. In the **Code Metrics Results** window, select the **Calculate Code Metrics for Solution** button.

The results are generated. To view the results details, expand the tree in the **Hierarchy** column.

![Screenshot of the Code Metrics window.](../code-quality/media/visualstudio/code-metrics-window.png)
::: moniker-end

::: moniker range="vs-2022"
### Generate code metrics results for an entire solution

You can generate code metrics results for an entire solution in any of the following ways:
Expand All @@ -83,6 +102,7 @@ The results are generated and the **Code Metrics Results** window is displayed.
1. From the menu bar, select **Analyze** > **Calculate Code Metrics** > **For Selected Project(s)**.

The results are generated and the **Code Metrics Results** window is displayed. To view the results details, expand the tree in the **Hierarchy**.
::: moniker-end

## Command-line code metrics

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 31 additions & 2 deletions docs/code-quality/working-with-code-metrics-data.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Code Metrics window
ms.date: 12/12/2017
ms.date: 1/22/2025
description: Learn how to view, filter, rearrange, and export Visual Studio code metrics analysis data. See how to create work items based on code metric results.
ms.topic: reference
f1_keywords:
Expand All @@ -15,8 +15,24 @@ manager: mijacobs
ms.subservice: code-analysis
---

# Use the Code Metrics Results window
# Use the Code Metrics window

::: moniker range="visualstudio"
The **Code Metrics** window displays the data that is generated by the code metrics analysis. For more information about code metrics data values, see [Code metrics values](../code-quality/code-metrics-values.md).

## Display code metrics results

You can display the Code Metrics window using the following sequence:

1. On the **View** menu, choose **Other Windows** > **Code Metrics**.

1. Select the **Calculate Code Metrics button** to generate results.

Results are scoped to the project or solution based on the current selection in Solution Explorer. Select either the project node or the solution node.

::: moniker-end

::: moniker range="vs-2022"
The **Code Metrics Results** window displays the data that is generated by the code metrics analysis. For more information about code metrics data values, see [Code metrics values](../code-quality/code-metrics-values.md).

## Display code metrics results
Expand All @@ -30,14 +46,21 @@ You can display the Code Metrics Results window using one of the following menu
- On the **View** menu, choose **Other Windows** > **Code Metrics Results**.

The **Code Metrics Results** window opens, even if it contains no results.
::: moniker-end

### To view code metrics details

If code metrics results have been generated, expand the tree in the **Hierarchy** column.

## Filter code metrics results

::: moniker range="visualstudio"
You can filter the results that are displayed in the **Code Metrics** window by using the toolbar at the top. For example, you might want to see only the results that have a maintainability index below 65.
::: moniker-end

::: moniker range="vs-2022"
You can filter the results that are displayed in the **Code Metrics Results** window by using the toolbar at the top. For example, you might want to see only the results that have a maintainability index below 65.
::: moniker-end

The **Filter** dropdown list box contains the names of the results columns. When a filter is defined, it is added to the bottom of the list together with an indentation. The list can contain the last 10 filters that were defined.

Expand All @@ -55,7 +78,13 @@ The **Filter** dropdown list box contains the names of the results columns. When

## Add, remove, and rearrange data columns

::: moniker range="visualstudio"
You can add or remove results columns from the **Code Metrics** window. In addition, you can rearrange results columns so that they appear in the order that you want.
::: moniker-end

::: moniker range="vs-2022"
You can add or remove results columns from the **Code Metrics Results** window. In addition, you can rearrange results columns so that they appear in the order that you want.
::: moniker-end

### Add or remove a column

Expand Down