Skip to content

Commit

Permalink
Fix more style warnings (#2089)
Browse files Browse the repository at this point in the history
Fix or suppress CA1000, S4023, S3442, S107, SA1402 and SA1649 warnings.
  • Loading branch information
iamdmitrij authored May 1, 2024
1 parent 3c642fd commit a31bdc2
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ tab_width = 2

# Put any C# specific settings here
dotnet_code_quality.CA1062.null_check_validation_methods = NotNull
dotnet_code_quality.CA1000.api_surface = private, internal

# S2094 // Classes should not be empty
dotnet_diagnostic.S2094.severity = suggestion

# SA1402 // File may only contain a single type
dotnet_diagnostic.SA1402.severity = none

# S4023 // Interfaces should not be empty
dotnet_diagnostic.S4023.severity = suggestion

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = true:error
csharp_style_expression_bodied_constructors = true:error
Expand Down
12 changes: 12 additions & 0 deletions Polly.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Snippets", "src\Snippets\Sn
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly.AotTest", "test\Polly.AotTest\Polly.AotTest.csproj", "{84091007-CFA5-4852-AC41-0171DF039C4E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "analyzers", "analyzers", "{4CB0EFF4-D867-4FA4-809D-C19F2F2A7C71}"
ProjectSection(SolutionItems) = preProject
eng\analyzers\BannedSymbols.txt = eng\analyzers\BannedSymbols.txt
eng\analyzers\Benchmark.globalconfig = eng\analyzers\Benchmark.globalconfig
eng\analyzers\Library.globalconfig = eng\analyzers\Library.globalconfig
eng\analyzers\SonarLint.xml = eng\analyzers\SonarLint.xml
eng\analyzers\Stylecop.globalconfig = eng\analyzers\Stylecop.globalconfig
eng\analyzers\Stylecop.json = eng\analyzers\Stylecop.json
eng\analyzers\Test.globalconfig = eng\analyzers\Test.globalconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -147,6 +158,7 @@ Global
{D333B5CE-982D-4C11-BDAF-4217AA02306E} = {A6CC41B9-E0B9-44F8-916B-3E4A78DA3BFB}
{D812B941-79B0-4E1E-BB70-4FAE345B5234} = {B7BF406B-B06F-4025-83E6-7219C53196A6}
{84091007-CFA5-4852-AC41-0171DF039C4E} = {A6CC41B9-E0B9-44F8-916B-3E4A78DA3BFB}
{4CB0EFF4-D867-4FA4-809D-C19F2F2A7C71} = {04E3C7C5-31F7-4CD6-8BEC-C1032527D231}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2E5D54CD-770A-4345-B585-1848FC2EA6F4}
Expand Down
9 changes: 9 additions & 0 deletions eng/analyzers/SonarLint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@
</Parameter>
</Parameters>
</Rule>
<Rule>
<Key>S107</Key>
<Parameters>
<Parameter>
<Key>max</Key>
<Value>12</Value>
</Parameter>
</Parameters>
</Rule>
</Rules>
</AnalysisInput>
2 changes: 1 addition & 1 deletion src/Polly/AsyncPolicy.TResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract partial class AsyncPolicy<TResult> : PolicyBase<TResult>
/// </summary>
/// <param name="exceptionPredicates">Predicates indicating which exceptions the policy should handle. </param>
/// <param name="resultPredicates">Predicates indicating which results the policy should handle. </param>
internal AsyncPolicy(
private protected AsyncPolicy(
ExceptionPredicates exceptionPredicates,
ResultPredicates<TResult> resultPredicates)
: base(exceptionPredicates, resultPredicates)
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/AsyncPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract partial class AsyncPolicy
/// Initializes a new instance of the <see cref="AsyncPolicy"/> class.
/// </summary>
/// <param name="exceptionPredicates">Predicates indicating which exceptions the policy should handle. </param>
internal AsyncPolicy(ExceptionPredicates exceptionPredicates)
private protected AsyncPolicy(ExceptionPredicates exceptionPredicates)
: base(exceptionPredicates)
{
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Polly/Policy.TResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract partial class Policy<TResult> : PolicyBase<TResult>
/// </summary>
/// <param name="exceptionPredicates">Predicates indicating which exceptions the policy should handle.</param>
/// <param name="resultPredicates">Predicates indicating which results the policy should handle.</param>
internal Policy(ExceptionPredicates exceptionPredicates, ResultPredicates<TResult> resultPredicates)
private protected Policy(ExceptionPredicates exceptionPredicates, ResultPredicates<TResult> resultPredicates)
: base(exceptionPredicates, resultPredicates)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Policy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract partial class Policy : PolicyBase
/// Initializes a new instance of the <see cref="Policy"/> class.
/// </summary>
/// <param name="exceptionPredicates">Predicates indicating which exceptions the policy should handle. </param>
internal Policy(ExceptionPredicates exceptionPredicates)
private protected Policy(ExceptionPredicates exceptionPredicates)
: base(exceptionPredicates)
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/Polly/PolicyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static ExceptionType GetExceptionType(ExceptionPredicates exceptionPred
/// Initializes a new instance of the <see cref="PolicyBase"/> class.
/// </summary>
/// <param name="exceptionPredicates">Predicates indicating which exceptions the policy should handle. </param>
internal PolicyBase(ExceptionPredicates exceptionPredicates) =>
private protected PolicyBase(ExceptionPredicates exceptionPredicates) =>
ExceptionPredicates = exceptionPredicates ?? ExceptionPredicates.None;

/// <summary>
Expand Down Expand Up @@ -62,7 +62,7 @@ public abstract class PolicyBase<TResult> : PolicyBase
/// </summary>
/// <param name="exceptionPredicates">Predicates indicating which exceptions the policy should handle. </param>
/// <param name="resultPredicates">Predicates indicating which results the policy should handle. </param>
internal PolicyBase(
private protected PolicyBase(
ExceptionPredicates exceptionPredicates,
ResultPredicates<TResult> resultPredicates)
: base(exceptionPredicates) =>
Expand Down
6 changes: 3 additions & 3 deletions src/Polly/Polly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<ProjectType>Library</ProjectType>
<MutationScore>70</MutationScore>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);S3872;SA1402;SA1414;S3215</NoWarn>
<NoWarn>$(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051</NoWarn>
<NoWarn>$(NoWarn);S3872;SA1414;S3215</NoWarn>
<NoWarn>$(NoWarn);IDE1006;CA1062;CA1068;S4039;CA1063;CA1031;CA1051</NoWarn>
<NoWarn>$(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033</NoWarn>
<NoWarn>$(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1623;SA1118</NoWarn>
<NoWarn>$(NoWarn);CA1010;CA1064;SA1623;SA1118</NoWarn>
<NoWarn>$(NoWarn);S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246</NoWarn>
<NoWarn>$(NoWarn);CA1805</NoWarn>

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a31bdc2

Please sign in to comment.