Skip to content

Commit

Permalink
Bump SonarAnalyzer.CSharp from 9.20.0.85982 to 9.25.1.91650 (#2129)
Browse files Browse the repository at this point in the history
* Bump SonarAnalyzer.CSharp from 9.20.0.85982 to 9.25.1.91650

Bumps [SonarAnalyzer.CSharp](https://github.com/SonarSource/sonar-dotnet) from 9.20.0.85982 to 9.25.1.91650.
- [Release notes](https://github.com/SonarSource/sonar-dotnet/releases)
- [Commits](SonarSource/sonar-dotnet@9.20.0.85982...9.25.1.91650)

---
updated-dependencies:
- dependency-name: SonarAnalyzer.CSharp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix new Sonar warnings

- Fix (or suppress) now Sonar code quality warnings.
- Sort and group the various suppressions in Polly.Specs.
- Suppress some new xunit analysis warnings.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: martincostello <[email protected]>
  • Loading branch information
dependabot[bot] and martincostello committed May 25, 2024
1 parent b607879 commit 0856394
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageVersion Include="Polly.Testing" Version="$(PollyVersion)" />
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageVersion Include="ReportGenerator" Version="5.3.0" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.20.0.85982" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.25.1.91650" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="4.5.0" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(MicrosoftExtensionsVersion)" />
Expand Down
2 changes: 2 additions & 0 deletions src/Polly.Core/Timeout/TimeoutResilienceStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public TimeoutResilienceStrategy(TimeoutStrategyOptions options, TimeProvider ti
// execution is finished, clean up
context.CancellationToken = previousToken;
#pragma warning disable CA1849 // Call async methods when in an async method, OK here as the callback is synchronous
#pragma warning disable S6966
registration.Dispose();
#pragma warning restore S6966
#pragma warning restore CA1849 // Call async methods when in an async method

_cancellationTokenSourcePool.Return(cancellationSource);
Expand Down
10 changes: 3 additions & 7 deletions src/Polly/Polly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
<ProjectType>Library</ProjectType>
<MutationScore>70</MutationScore>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);SA1414;S3215</NoWarn>
<NoWarn>$(NoWarn);CA1062;CA1068;S4039;CA1063;CA1031;CA1051</NoWarn>
<NoWarn>$(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;CA1033</NoWarn>
<NoWarn>$(NoWarn);CA1010;CA1064;SA1118</NoWarn>
<NoWarn>$(NoWarn);S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246</NoWarn>
<NoWarn>$(NoWarn);CA1805</NoWarn>

<NoWarn>$(NoWarn);CA1010;CA1031;CA1032;CA1033;CA1051;CA1062;CA1063;CA1064;CA1068;CA1710;CA1716;CA1724;CA1805;CA1815;CA1816;CA2211</NoWarn>
<NoWarn>$(NoWarn);S2223;S3215;S3246;S3971;S4039;S4049;S4457</NoWarn>
<NoWarn>$(NoWarn);SA1108;SA1118;SA1414</NoWarn>
<!--Public API Analyzers: We do not need to fix these as it would break compatibility with released Polly versions-->
<NoWarn>$(NoWarn);RS0037;</NoWarn>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Core.Tests/Polly.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ProjectType>Test</ProjectType>
<Nullable>enable</Nullable>
<Threshold>100</Threshold>
<NoWarn>$(NoWarn);SA1600;SA1204</NoWarn>
<NoWarn>$(NoWarn);S6966;SA1600;SA1204</NoWarn>
<Include>[Polly.Core]*</Include>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public async Task Dispose_DisposableResourcesShouldBeDisposed(bool isAsync)
}
else
{
#pragma warning disable S6966
strategy.Dispose();
#pragma warning restore S6966
}

await limiter.Invoking(l => l.AcquireAsync(1).AsTask()).Should().ThrowAsync<ObjectDisposedException>();
Expand Down Expand Up @@ -130,7 +132,7 @@ private void SetupLimiter(CancellationToken token)
_limiter
.GetType()
.GetMethod("AcquireAsyncCore", BindingFlags.NonPublic | BindingFlags.Instance)!
.Invoke(_limiter, new object[] { 1, token })
.Invoke(_limiter, [1, token])
.Returns(result);
}

Expand Down
15 changes: 13 additions & 2 deletions test/Polly.Specs/CircuitBreaker/CircuitBreakerTResultAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,11 @@ public async Task Should_only_allow_single_execution_on_first_entering_halfopen_
// Graceful cleanup: allow executions time to end naturally; signal them to end if not; timeout any deadlocks; expose any execution faults. This validates the test ran as expected (and background delegates are complete) before we assert on outcomes.
permitFirstExecutionEnd.WaitOne(testTimeoutToExposeDeadlocks);
permitFirstExecutionEnd.Set();
Task.WaitAll(new[] { firstExecution, secondExecution }, testTimeoutToExposeDeadlocks).Should().BeTrue();

#pragma warning disable xUnit1031
Task.WaitAll([firstExecution, secondExecution], testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031

if (firstExecution.IsFaulted)
throw firstExecution!.Exception!;
if (secondExecution.IsFaulted)
Expand Down Expand Up @@ -625,7 +629,11 @@ public async Task Should_allow_single_execution_per_break_duration_in_halfopen_s
// Graceful cleanup: allow executions time to end naturally; signal them to end if not; timeout any deadlocks; expose any execution faults. This validates the test ran as expected (and background delegates are complete) before we assert on outcomes.
permitFirstExecutionEnd.WaitOne(testTimeoutToExposeDeadlocks);
permitFirstExecutionEnd.Set();
Task.WaitAll(new[] { firstExecution, secondExecution }, testTimeoutToExposeDeadlocks).Should().BeTrue();

#pragma warning disable xUnit1031
Task.WaitAll([firstExecution, secondExecution], testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031

if (firstExecution.IsFaulted)
throw firstExecution!.Exception!;
if (secondExecution.IsFaulted)
Expand Down Expand Up @@ -890,8 +898,11 @@ public async Task Should_call_onbreak_when_breaking_circuit_first_time_but_not_f
// Permit the second (long-running) execution to hit the open circuit with its failure.
permitLongRunningExecutionToReturnItsFailure.Set();

#pragma warning disable xUnit1031
// Graceful cleanup: allow executions time to end naturally; timeout if any deadlocks; expose any execution faults. This validates the test ran as expected (and background delegates are complete) before we assert on outcomes.
longRunningExecution.Wait(testTimeoutToExposeDeadlocks).Should().BeTrue();
#pragma warning restore xUnit1031

if (longRunningExecution.IsFaulted)
throw longRunningExecution!.Exception!;
longRunningExecution.Status.Should().Be(TaskStatus.RanToCompletion);
Expand Down
7 changes: 4 additions & 3 deletions test/Polly.Specs/Polly.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
<Threshold>75,60,70</Threshold>
<Include>[Polly]*</Include>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);S103;S104;IDE0011;SA1600;SA1204;CA2008;CA2201;</NoWarn>
<NoWarn>$(NoWarn);S3878;CA1030;S1402;SA1649;SA1402;CA1031</NoWarn>
<NoWarn>$(NoWarn);S2184;</NoWarn>
<NoWarn>$(NoWarn);CA1030;CA1031;CA2008;CA2201</NoWarn>
<NoWarn>$(NoWarn);IDE0011</NoWarn>
<NoWarn>$(NoWarn);S103;S104;S2184;S3878;S6966</NoWarn>
<NoWarn>$(NoWarn);SA1204;SA1402;SA1600;SA1649</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 0856394

Please sign in to comment.