You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/code-quality/clang-tidy.md
+38-1Lines changed: 38 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -31,14 +31,51 @@ For more information, see [How to: Set Code Analysis Properties for C/C++ Projec
31
31
32
32
## CMake
33
33
34
-
In CMake projects, you can configure Clang-Tidy checks within *`CMakeSettings.json`*. Once opened, select "Edit JSON" in the top right-hand corner of the CMake Project Settings Editor. The following keys are recognized:
34
+
In CMake projects, you can configure Clang-Tidy checks within *`CMakeSettings.json`* or *`CMakePresets.json`*.
35
+
36
+
The following keys are recognized for clang-tidy:
35
37
36
38
-`enableMicrosoftCodeAnalysis`: Enables Microsoft Code Analysis
-`clangTidyChecks`: Clang-Tidy configuration, specified as a comma-separated list, that is, checks to be enabled or disabled
39
41
40
42
If neither of the "enable" options are specified, Visual Studio will select the analysis tool matching the Platform Toolset used.
41
43
44
+
### CMake Settings
45
+
To edit your clang-tidy settings, open your CMake Settings, select "Edit JSON" in the top right-hand corner of the CMake Project Settings Editor. You can use the keys above to fill out your clang-tidy specifications in the CMake Settings json file.
46
+
An example CMake settings implementation would look like this:
47
+
```
48
+
{
49
+
"configurations": [
50
+
{
51
+
"name": "x64-debug",
52
+
"generator": "Ninja",
53
+
....
54
+
"clangTidyChecks": "",
55
+
"enableMicrosoftCodeAnalysis": true,
56
+
"enableClangTidyCodeAnalysis": true
57
+
}
58
+
]
59
+
}
60
+
```
61
+
62
+
### CMake Presets
63
+
The same keys can be used in your CMake presets via the `vendor` object.
64
+
An example CMake preset implementation would look like this:
65
+
```"configurePreset": [
66
+
{ "name": "base",
67
+
....
68
+
"vendor": {
69
+
"microsoft.com/VisualStudioSettings/CMake/1.0": {
70
+
"clangTidyChecks": "",
71
+
"enableMicrosoftCodeAnalysis": true,
72
+
"enableClangTidyCodeAnalysis": true
73
+
}
74
+
}
75
+
}
76
+
]
77
+
```
78
+
42
79
## Warning display
43
80
44
81
Clang-Tidy runs result in warnings displayed in the Error List, and as in-editor squiggles underneath relevant sections of code. Use the "Category" column in the Error List to sort and organize Clang-Tidy warnings. You can configure in-editor warnings by toggling the "Disable Code Analysis Squiggles" setting under **Tools** > **Options**.
0 commit comments