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

Update to StyleCop.Analyzers 1.2.0-beta.556 #869

Merged
merged 3 commits into from
Mar 3, 2024
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ dotnet_diagnostic.SA1006.severity = suggestion # SA1006: Preprocessor keywords
dotnet_diagnostic.SA1007.severity = suggestion # SA1007: Operator keyword should be followed by space
dotnet_diagnostic.SA1008.severity = suggestion # SA1008: Opening parenthesis should be spaced correctly
dotnet_diagnostic.SA1009.severity = suggestion # SA1009: Closing parenthesis should be spaced correctly
dotnet_diagnostic.SA1010.severity = none # SA1010: Opening square brackets should be spaced correctly # TODO review this, temporarily disabled until https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687 is resolved. Hopefully soon by merging https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/3729
dotnet_diagnostic.SA1010.severity = suggestion # SA1010: Opening square brackets should be spaced correctly
dotnet_diagnostic.SA1011.severity = suggestion # SA1011: Closing square brackets should be spaced correctly
dotnet_diagnostic.SA1012.severity = suggestion # SA1012: Opening braces should be spaced correctly
dotnet_diagnostic.SA1013.severity = suggestion # SA1013: Closing braces should be spaced correctly
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
HttpClientMockTypes.Typed => HttpResponseMessageMockDescriptor.Typed(_httpClientType!, _httpClientName!, _httpResponseMessageMockBuilder),
HttpClientMockTypes.Named => HttpResponseMessageMockDescriptor.Named(_httpClientName!, _httpResponseMessageMockBuilder),
HttpClientMockTypes.Basic => HttpResponseMessageMockDescriptor.Basic(_httpResponseMessageMockBuilder),
_ => throw new InvalidOperationException($"Unexpected value for {typeof(HttpClientMockTypes)}: {_httpClientMockType}")
_ => throw new InvalidOperationException($"Unexpected value for {typeof(HttpClientMockTypes)}: {_httpClientMockType}"),

Check warning on line 87 in src/DotNet.Sdk.Extensions.Testing/HttpMocking/InProcess/ResponseMocking/HttpResponseMessageMockDescriptorBuilder.cs

View check run for this annotation

Codecov / codecov/patch

src/DotNet.Sdk.Extensions.Testing/HttpMocking/InProcess/ResponseMocking/HttpResponseMessageMockDescriptorBuilder.cs#L87

Added line #L87 was not covered by tests
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
return exception switch
{
{ InnerException: TimeoutException } => Task.FromResult<HttpResponseMessage>(new TimeoutHttpResponseMessage(exception)),
_ => Task.FromResult<HttpResponseMessage>(new AbortedHttpResponseMessage(exception))
_ => Task.FromResult<HttpResponseMessage>(new AbortedHttpResponseMessage(exception)),
};
},
onFallbackAsync: (outcome, context) =>
Expand All @@ -55,7 +55,7 @@
{
IsolatedCircuitException => new CircuitBrokenHttpResponseMessage(CircuitBreakerState.Isolated, exception),
BrokenCircuitException => new CircuitBrokenHttpResponseMessage(CircuitBreakerState.Open, exception),
_ => throw new InvalidOperationException($"Unexpected circuit breaker exception type: {delegateResult.Exception.GetType()}")
_ => throw new InvalidOperationException($"Unexpected circuit breaker exception type: {delegateResult.Exception.GetType()}"),

Check warning on line 58 in src/DotNet.Sdk.Extensions/Polly/Http/Fallback/FallbackPolicyFactory.cs

View check run for this annotation

Codecov / codecov/patch

src/DotNet.Sdk.Extensions/Polly/Http/Fallback/FallbackPolicyFactory.cs#L58

Added line #L58 was not covered by tests
};
return Task.FromResult<HttpResponseMessage>(response);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@ namespace DotNet.Sdk.Extensions.Polly.Http.Resilience.Events;
/// <summary>
/// Defines the events produced by the HttpClient's resilience policies.
/// </summary>
#pragma warning disable RCS1251 // Remove unnecessary braces from record declaration
// Shouldn't have to disable RCS1251 but if I fix it then the StyleCopAnalyzers starts
// crashing. For now I'm ignoring RCS1251 hoping the StyleCopAnalyzers get updated
// soon, if not, consider removing the StyleCopAnalyzers
public interface IResiliencePoliciesEventHandler :
ITimeoutPolicyEventHandler,
IRetryPolicyEventHandler,
ICircuitBreakerPolicyEventHandler,
IFallbackPolicyEventHandler
{
}
#pragma warning restore RCS1251 // Remove unnecessary braces from record declaration
IFallbackPolicyEventHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ namespace DotNet.Sdk.Extensions.Polly.Http.Resilience.Extensions;
/// </summary>
public static class ResiliencePoliciesHttpClientBuilderExtensions
{
// Shouldn't have to disable RCS1251 but if I fix it then the StyleCopAnalyzers starts
// crashing. For now I'm ignoring RCS1251 hoping the StyleCopAnalyzers get updated
// soon, if not, consider removing the StyleCopAnalyzers
#pragma warning disable RCS1251 // Remove unnecessary braces from record declaration
private sealed class BlankHttpMessageHandler : DelegatingHandler
{
}
#pragma warning restore RCS1251 // Remove unnecessary braces from record declaration
private sealed class BlankHttpMessageHandler : DelegatingHandler;

/// <summary>
/// Adds resilience policies to the <see cref="HttpClient"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
CircuitState.Isolated => ExecuteFallbackValueFactoryAsync(CircuitBreakerState.Isolated),
CircuitState.Open => ExecuteFallbackValueFactoryAsync(CircuitBreakerState.Open),
CircuitState.Closed or CircuitState.HalfOpen => ExecutePolicyActionAsync(),
_ => throw new InvalidOperationException($"Unexpected circuit state: {_circuitBreakerPolicy.CircuitState}.")
_ => throw new InvalidOperationException($"Unexpected circuit state: {_circuitBreakerPolicy.CircuitState}."),

Check warning on line 72 in src/DotNet.Sdk.Extensions/Polly/Policies/CircuitBreakerCheckerAsyncPolicy.cs

View check run for this annotation

Codecov / codecov/patch

src/DotNet.Sdk.Extensions/Polly/Policies/CircuitBreakerCheckerAsyncPolicy.cs#L72

Added line #L72 was not covered by tests
};

async Task<T> ExecuteFallbackValueFactoryAsync(CircuitBreakerState circuitBreakerState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ public void ValidateArguments1(
Type exceptionType,
string exceptionMessage)
{
var exception = Should.Throw(() =>
{
hostBuilder.AddTestAppSettings(appSettingsFilename, otherAppSettingsFilenames);
}, exceptionType);
var exception = Should.Throw(
() => hostBuilder.AddTestAppSettings(appSettingsFilename, otherAppSettingsFilenames),
exceptionType);
exception.Message.ShouldBe(exceptionMessage);
}

Expand Down Expand Up @@ -80,10 +79,9 @@ public void ValidateArguments2(
Type exceptionType,
string exceptionMessage)
{
var exception = Should.Throw(() =>
{
hostBuilder.AddTestAppSettings(configureOptions, appSettingsFilename, otherAppSettingsFilenames);
}, exceptionType);
var exception = Should.Throw(
() => hostBuilder.AddTestAppSettings(configureOptions, appSettingsFilename, otherAppSettingsFilenames),
exceptionType);
exception.Message.ShouldBe(exceptionMessage);
}

Expand Down Expand Up @@ -163,7 +161,8 @@ public void SelectDirAbsolute()
{
options.AppSettingsDir = Path.Combine(Directory.GetCurrentDirectory(), "Configuration");
options.IsRelative = false;
}, "appsettings.test.json")
},
"appsettings.test.json")
.Build();
var configuration = (ConfigurationRoot)host.Services.GetRequiredService<IConfiguration>();
var jsonConfigurationProviders = configuration.Providers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ public void ValidateArguments1(
Type exceptionType,
string exceptionMessage)
{
var exception = Should.Throw(() =>
{
webHostBuilder.AddTestAppSettings(appSettingsFilename, otherAppSettingsFilenames);
}, exceptionType);
var exception = Should.Throw(
() => webHostBuilder.AddTestAppSettings(appSettingsFilename, otherAppSettingsFilenames),
exceptionType);
exception.Message.ShouldBe(exceptionMessage);
}

Expand Down Expand Up @@ -87,10 +86,9 @@ public void ValidateArguments2(
Type exceptionType,
string exceptionMessage)
{
var exception = Should.Throw(() =>
{
webHostBuilder.AddTestAppSettings(configureOptions, appSettingsFilename, otherAppSettingsFilenames);
}, exceptionType);
var exception = Should.Throw(
() => webHostBuilder.AddTestAppSettings(configureOptions, appSettingsFilename, otherAppSettingsFilenames),
exceptionType);
exception.Message.ShouldBe(exceptionMessage);
}

Expand Down Expand Up @@ -190,7 +188,8 @@ public void SelectDirAbsolute()
{
options.AppSettingsDir = Path.Combine(Directory.GetCurrentDirectory(), "Configuration");
options.IsRelative = false;
}, "appsettings.test.json")
},
"appsettings.test.json")
.Build();
var configuration = (ConfigurationRoot)webHost.Services.GetRequiredService<IConfiguration>();
var jsonConfigurationProviders = configuration.Providers
Expand Down
Loading