Skip to content

Commit 0f673ab

Browse files
committed
Proj0038: Specify NoWarn rule IDs fully
1 parent fd8ee92 commit 0f673ab

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ reported a the [GibHub repository](https://github.com/dotnet-project-file-analyz
8989
* [**Proj0035** Remove deprecated RestoreProjectStyle property](rules/Proj0035.md)
9090
* [**Proj0036** Remove None when redundant](rules/Proj0036.md)
9191
* [**Proj0037** Exclude runtime when all assets are private](rules/Proj0037.md)
92+
* [**Proj0038** Specify NoWarn rule IDs fully](rules/Proj0038.md)
9293

9394
### Packaging
9495
* [**Proj0200** Define IsPackable explicitly](rules/Proj0200.md)

rules/Proj0038.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
parent: General
3+
ancestor: MSBuild
4+
---
5+
6+
# Proj0038: Specify NoWarn rule IDs fully
7+
MS Build allows to disable a static code analysis rule by adding it to the
8+
`<NoWarn>` property. It excepts rule IDs that are only specified by their
9+
numeric part. The latter is considered a bad practice: it can lead to excluding
10+
multiple rules at once that have the same integer part, and make it less
11+
trivial to understand which rule has been disabled.
12+
13+
## Non-compliant
14+
``` xml
15+
<Project Sdk="Microsoft.NET.Sdk">
16+
17+
<PropertyGroup>
18+
<TargetFramework>net8.0</TargetFramework>
19+
<NoWarn>1825</NoWarn>
20+
</PropertyGroup>
21+
22+
</Project>
23+
```
24+
25+
## Compliant
26+
``` xml
27+
<Project Sdk="Microsoft.NET.Sdk">
28+
29+
<PropertyGroup>
30+
<TargetFramework>net8.0</TargetFramework>
31+
<NoWarn>CA1825</NoWarn>
32+
</PropertyGroup>
33+
34+
</Project>
35+
```

0 commit comments

Comments
 (0)