Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SA1111/SA1513/SA1121/SA1110 #1939

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Polly/AsyncPolicy.GenericImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ protected abstract Task<TResult> ImplementationAsync(
Func<Context, CancellationToken, Task<TResult>> action,
Context context,
CancellationToken cancellationToken,
bool continueOnCapturedContext
);
bool continueOnCapturedContext);
}
3 changes: 1 addition & 2 deletions src/Polly/AsyncPolicy.NonGenericImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ protected abstract Task<TResult> ImplementationAsync<TResult>(
Func<Context, CancellationToken, Task<TResult>> action,
Context context,
CancellationToken cancellationToken,
bool continueOnCapturedContext
);
bool continueOnCapturedContext);
}
1 change: 1 addition & 0 deletions src/Polly/Bulkhead/AsyncBulkheadEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal static async Task<TResult> ImplementationAsync<TResult>(
await onBulkheadRejectedAsync(context).ConfigureAwait(continueOnCapturedContext);
throw new BulkheadRejectedException();
}

try
{
await maxParallelizationSemaphore.WaitAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext);
Expand Down
3 changes: 1 addition & 2 deletions src/Polly/Bulkhead/AsyncBulkheadSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public static AsyncBulkheadPolicy BulkheadAsync(
return new AsyncBulkheadPolicy(
maxParallelization,
maxQueuingActions,
onBulkheadRejectedAsync
);
onBulkheadRejectedAsync);
}
}
3 changes: 1 addition & 2 deletions src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public static AsyncBulkheadPolicy<TResult> BulkheadAsync<TResult>(int maxParalle
return new AsyncBulkheadPolicy<TResult>(
maxParallelization,
maxQueuingActions,
onBulkheadRejectedAsync
);
onBulkheadRejectedAsync);
}
}
3 changes: 1 addition & 2 deletions src/Polly/Bulkhead/BulkheadSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public static BulkheadPolicy Bulkhead(int maxParallelization, int maxQueuingActi
return new BulkheadPolicy(
maxParallelization,
maxQueuingActions,
onBulkheadRejected
);
onBulkheadRejected);
}
}
3 changes: 1 addition & 2 deletions src/Polly/Bulkhead/BulkheadTResultSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public static BulkheadPolicy<TResult> Bulkhead<TResult>(int maxParallelization,
return new BulkheadPolicy<TResult>(
maxParallelization,
maxQueuingActions,
onBulkheadRejected
);
onBulkheadRejected);
}
}
1 change: 1 addition & 0 deletions src/Polly/Caching/AsyncCacheEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal static async Task<TResult> ImplementationAsync<TResult>(
valueFromCache = default;
onCacheGetError?.Invoke(context, cacheKey, ex);
}

if (cacheHit)
{
onCacheGet(context, cacheKey);
Expand Down
6 changes: 2 additions & 4 deletions src/Polly/Caching/AsyncSerializingCacheProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public Task PutAsync(string key, object? value, Ttl ttl, CancellationToken cance
_serializer.Serialize(value),
ttl,
cancellationToken,
continueOnCapturedContext
);
continueOnCapturedContext);
}

/// <summary>
Expand Down Expand Up @@ -114,6 +113,5 @@ public Task PutAsync(string key, TResult? value, Ttl ttl, CancellationToken canc
_serializer.Serialize(value),
ttl,
cancellationToken,
continueOnCapturedContext
);
continueOnCapturedContext);
}
1 change: 1 addition & 0 deletions src/Polly/Caching/CacheEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal static TResult Implementation<TResult>(
valueFromCache = default;
onCacheGetError?.Invoke(context, cacheKey, ex);
}

if (cacheHit)
{
onCacheGet(context, cacheKey);
Expand Down
18 changes: 6 additions & 12 deletions src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this PolicyBuilder pol
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
doNothingOnBreak,
doNothingOnReset
);
doNothingOnReset);
}

/// <summary>
Expand Down Expand Up @@ -72,8 +71,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this PolicyBuilder pol
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
(exception, timespan, _) => onBreak(exception, timespan),
_ => onReset()
);
_ => onReset());

/// <summary>
/// <para>The circuit will break if, within any timeslice of duration <paramref name="samplingDuration"/>, the proportion of actions resulting in a handled exception exceeds <paramref name="failureThreshold"/>, provided also that the number of actions through the circuit in the timeslice is at least <paramref name="minimumThroughput" />. </para>
Expand Down Expand Up @@ -108,8 +106,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this PolicyBuilder pol
durationOfBreak,
onBreak,
onReset,
doNothingOnHalfOpen
);
doNothingOnHalfOpen);
}

/// <summary>
Expand Down Expand Up @@ -146,8 +143,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this PolicyBuilder pol
durationOfBreak,
(exception, timespan, _) => onBreak(exception, timespan),
_ => onReset(),
onHalfOpen
);
onHalfOpen);

/// <summary>
/// <para> Builds a <see cref="Policy" /> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -184,8 +180,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this PolicyBuilder pol
durationOfBreak,
(exception, _, timespan, context) => onBreak(exception, timespan, context),
onReset,
onHalfOpen
);
onHalfOpen);

/// <summary>
/// <para> Builds a <see cref="Policy" /> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -240,7 +235,6 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this PolicyBuilder pol
onHalfOpen);
return new CircuitBreakerPolicy(
policyBuilder,
breakerController
);
breakerController);
}
}
19 changes: 7 additions & 12 deletions src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
doNothingOnBreak,
doNothingOnReset
);
doNothingOnReset);

Check warning on line 40 in src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs#L40

Added line #L40 was not covered by tests
}

/// <summary>
Expand Down Expand Up @@ -72,8 +71,7 @@
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
(outcome, timespan, _) => onBreak(outcome, timespan),
_ => onReset()
);
_ => onReset());

Check warning on line 74 in src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs#L74

Added line #L74 was not covered by tests

/// <summary>
/// <para>The circuit will break if, within any timeslice of duration <paramref name="samplingDuration"/>, the proportion of actions resulting in a handled exception or result exceeds <paramref name="failureThreshold"/>, provided also that the number of actions through the circuit in the timeslice is at least <paramref name="minimumThroughput" />. </para>
Expand Down Expand Up @@ -108,8 +106,7 @@
durationOfBreak,
onBreak,
onReset,
doNothingOnHalfOpen
);
doNothingOnHalfOpen);

Check warning on line 109 in src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs#L109

Added line #L109 was not covered by tests
}

/// <summary>
Expand Down Expand Up @@ -146,8 +143,7 @@
durationOfBreak,
(outcome, timespan, _) => onBreak(outcome, timespan),
_ => onReset(),
onHalfOpen
);
onHalfOpen);

Check warning on line 146 in src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs#L146

Added line #L146 was not covered by tests

/// <summary>
/// <para> Builds a <see cref="Policy{TResult}" /> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -185,8 +181,7 @@
durationOfBreak,
(outcome, _, timespan, context) => onBreak(outcome, timespan, context),
onReset,
onHalfOpen
);
onHalfOpen);

Check warning on line 184 in src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs#L184

Added line #L184 was not covered by tests

/// <summary>
/// <para> Builds a <see cref="Policy{TResult}" /> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -240,9 +235,9 @@
onBreak,
onReset,
onHalfOpen);

return new CircuitBreakerPolicy<TResult>(
policyBuilder,
breakerController
);
breakerController);

Check warning on line 241 in src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs#L241

Added line #L241 was not covered by tests
}
}
4 changes: 2 additions & 2 deletions src/Polly/CircuitBreaker/AdvancedCircuitController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public AdvancedCircuitController(
TimeSpan durationOfBreak,
Action<DelegateResult<TResult>, CircuitState, TimeSpan, Context> onBreak,
Action<Context> onReset,
Action onHalfOpen
)
Action onHalfOpen)
: base(durationOfBreak, onBreak, onReset, onHalfOpen)
{
_metrics = samplingDuration.Ticks < ResolutionOfCircuitTimer * NumberOfWindows
Expand Down Expand Up @@ -85,6 +84,7 @@ public override void OnActionFailure(DelegateResult<TResult> outcome, Context co
{
Break_NeedsLock(context);
}

break;

case CircuitState.Open:
Expand Down
19 changes: 7 additions & 12 deletions src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(this PolicyB
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
doNothingOnBreak,
doNothingOnReset
);
doNothingOnReset);
}

/// <summary>
Expand Down Expand Up @@ -74,8 +73,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(this PolicyB
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
(exception, timespan, _) => onBreak(exception, timespan),
_ => onReset()
);
_ => onReset());

/// <summary>
/// <para> Builds a <see cref="AsyncPolicy"/> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -112,8 +110,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(this PolicyB
durationOfBreak,
onBreak,
onReset,
doNothingOnHalfOpen
);
doNothingOnHalfOpen);
}

/// <summary>
Expand Down Expand Up @@ -150,8 +147,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(this PolicyB
durationOfBreak,
(exception, timespan, _) => onBreak(exception, timespan),
_ => onReset(),
onHalfOpen
);
onHalfOpen);

/// <summary>
/// <para> Builds a <see cref="AsyncPolicy"/> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -188,8 +184,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(this PolicyB
durationOfBreak,
(exception, _, timespan, context) => onBreak(exception, timespan, context),
onReset,
onHalfOpen
);
onHalfOpen);

/// <summary>
/// <para> Builds a <see cref="AsyncPolicy"/> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -242,9 +237,9 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync(this PolicyB
(outcome, state, timespan, context) => onBreak(outcome.Exception, state, timespan, context),
onReset,
onHalfOpen);

return new AsyncCircuitBreakerPolicy(
policyBuilder,
breakerController
);
breakerController);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
doNothingOnBreak,
doNothingOnReset
);
doNothingOnReset);

Check warning on line 40 in src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L40

Added line #L40 was not covered by tests
}

/// <summary>
Expand Down Expand Up @@ -73,8 +72,7 @@
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
(outcome, timespan, _) => onBreak(outcome, timespan),
_ => onReset()
);
_ => onReset());

Check warning on line 75 in src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L75

Added line #L75 was not covered by tests

/// <summary>
/// <para> Builds a <see cref="AsyncPolicy{TResult}"/> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -106,13 +104,13 @@
public static AsyncCircuitBreakerPolicy<TResult> AdvancedCircuitBreakerAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, double failureThreshold, TimeSpan samplingDuration, int minimumThroughput, TimeSpan durationOfBreak, Action<DelegateResult<TResult>, TimeSpan, Context> onBreak, Action<Context> onReset)
{
Action doNothingOnHalfOpen = () => { };

return policyBuilder.AdvancedCircuitBreakerAsync(
failureThreshold, samplingDuration, minimumThroughput,
durationOfBreak,
onBreak,
onReset,
doNothingOnHalfOpen
);
doNothingOnHalfOpen);

Check warning on line 113 in src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L113

Added line #L113 was not covered by tests
}

/// <summary>
Expand Down Expand Up @@ -149,8 +147,7 @@
durationOfBreak,
(outcome, timespan, _) => onBreak(outcome, timespan),
_ => onReset(),
onHalfOpen
);
onHalfOpen);

Check warning on line 150 in src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L150

Added line #L150 was not covered by tests

/// <summary>
/// <para> Builds a <see cref="AsyncPolicy{TResult}"/> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -187,8 +184,7 @@
durationOfBreak,
(outcome, _, timespan, context) => onBreak(outcome, timespan, context),
onReset,
onHalfOpen
);
onHalfOpen);

Check warning on line 187 in src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L187

Added line #L187 was not covered by tests

/// <summary>
/// <para> Builds a <see cref="AsyncPolicy{TResult}"/> that will function like a Circuit Breaker.</para>
Expand Down Expand Up @@ -241,9 +237,9 @@
onBreak,
onReset,
onHalfOpen);

return new AsyncCircuitBreakerPolicy<TResult>(
policyBuilder,
breakerController
);
breakerController);

Check warning on line 243 in src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs#L243

Added line #L243 was not covered by tests
}
}
6 changes: 2 additions & 4 deletions src/Polly/CircuitBreaker/AsyncCircuitBreakerPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public class AsyncCircuitBreakerPolicy : AsyncPolicy, ICircuitBreakerPolicy

internal AsyncCircuitBreakerPolicy(
PolicyBuilder policyBuilder,
ICircuitController<EmptyStruct> breakerController
)
ICircuitController<EmptyStruct> breakerController)
: base(policyBuilder) =>
_breakerController = breakerController;

Expand Down Expand Up @@ -64,8 +63,7 @@ public class AsyncCircuitBreakerPolicy<TResult> : AsyncPolicy<TResult>, ICircuit

internal AsyncCircuitBreakerPolicy(
PolicyBuilder<TResult> policyBuilder,
ICircuitController<TResult> breakerController
)
ICircuitController<TResult> breakerController)
: base(policyBuilder) =>
_breakerController = breakerController;

Expand Down
Loading
Loading