-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
58 lines (47 loc) · 2.56 KB
/
Copy pathDirectory.Build.props
File metadata and controls
58 lines (47 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseArtifactsOutput>true</UseArtifactsOutput>
</PropertyGroup>
<!--
Cognitive Complexity (SonarSource rule S3776), opt-in.
Normal builds are unaffected. To check it, build with the flag:
dotnet build -p:MeasureCognitiveComplexity=true
This pulls in the SonarAnalyzer.CSharp Roslyn analyzer and silences every
rule except S3776. With the default SonarLint.xml threshold (15), S3776
warns for any method that exceeds the recommended per-method maximum:
S3776: Refactor this method to reduce its Cognitive Complexity from N ...
The CI "cognitive-complexity" job escalates that warning to an error
(-p:WarningsAsErrors=S3776), so a method above 15 fails the build. Lower the
SonarLint.xml threshold to 0 for a full per-method census of every method's N.
Remove the three files (Directory.Build.props, cognitive-complexity.globalconfig,
SonarLint.xml) to unwire it entirely.
-->
<PropertyGroup>
<MeasureCognitiveComplexity Condition="'$(MeasureCognitiveComplexity)' == ''">false</MeasureCognitiveComplexity>
</PropertyGroup>
<ItemGroup Condition="'$(MeasureCognitiveComplexity)' == 'true'">
<!-- Pinned (not floating) in Directory.Packages.props so the CI gate is deterministic and
reproducible locally: a new analyzer release changing S3776 scoring must arrive as a
deliberate version bump, not silently fail an unrelated PR. -->
<PackageReference Include="SonarAnalyzer.CSharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)cognitive-complexity.globalconfig" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)SonarLint.xml" />
</ItemGroup>
<ItemGroup Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('.Tests'))">
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>