Skip to content

Commit

Permalink
Fix S2184 and S2104 (#2328)
Browse files Browse the repository at this point in the history
* Fix SA1204

* Fix warning S2184

* Remove S2184 and SA1204 warning supressions
  • Loading branch information
ShawnWu33 authored Oct 5, 2024
1 parent 439cf15 commit 3392a33
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
[Collection(Constants.ParallelThreadDependentTestCollection)]
public abstract class BulkheadSpecsBase : IDisposable
{
protected static AssertionFailure? Expect(int expected, Func<int> actualFunc, string measure)
{
int actual = actualFunc();
return actual != expected ? new AssertionFailure(expected, actual, measure) : null;
}

#region Time constraints

protected readonly TimeSpan ShimTimeSpan = TimeSpan.FromMilliseconds(50); // How frequently to retry the assertions.
Expand Down Expand Up @@ -312,12 +318,6 @@ protected void EnsureNoUnbservedTaskExceptions()

#endregion

protected static AssertionFailure? Expect(int expected, Func<int> actualFunc, string measure)
{
int actual = actualFunc();
return actual != expected ? new AssertionFailure(expected, actual, measure) : null;
}

protected void Within(TimeSpan timeSpan, Func<AssertionFailure?> actionContainingAssertions)
{
TimeSpan permitted = timeSpan;
Expand Down
4 changes: 2 additions & 2 deletions test/Polly.Specs/Polly.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<Include>[Polly]*</Include>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);CA1030;CA1031;CA2008;CA2201</NoWarn>
<NoWarn>$(NoWarn);S104;S2184;S6966</NoWarn>
<NoWarn>$(NoWarn);SA1204;SA1402;SA1600</NoWarn>
<NoWarn>$(NoWarn);S104;S6966</NoWarn>
<NoWarn>$(NoWarn);SA1402;SA1600</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Retry/WaitAndRetryAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ public async Task Should_honour_cancellation_immediately_during_wait_phase_of_wa
attemptsInvoked.Should().Be(1);

watch.Elapsed.Should().BeLessThan(retryDelay);
watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds((int)shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments.
watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds(shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments.
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Retry/WaitAndRetrySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ public void Should_honour_cancellation_immediately_during_wait_phase_of_waitandr
attemptsInvoked.Should().Be(1);

watch.Elapsed.Should().BeLessThan(retryDelay);
watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds((int)shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments.
watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds(shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments.
}

[Fact]
Expand Down

0 comments on commit 3392a33

Please sign in to comment.