Skip to content

Commit 9689db6

Browse files
committed
Fix all violations of SA1117 (ParametersMustBeOnSameLineOrSeparateLines)
1 parent 2c5b806 commit 9689db6

12 files changed

Lines changed: 111 additions & 45 deletions

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ private async Task TestConstructorMissingDocumentationAsync(string typeKind, str
542542

543543
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(5, 13);
544544

545-
await this.VerifyCSharpDiagnosticAsync(
546-
testCode,
547-
expected, CancellationToken.None).ConfigureAwait(false);
545+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
548546

549547
var fixedCode = @"namespace FooNamespace
550548
{{

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1643UnitTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ public class Foo{0}
182182

183183
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(5, 13);
184184

185-
await this.VerifyCSharpDiagnosticAsync(
186-
testCode,
187-
expected, CancellationToken.None).ConfigureAwait(false);
185+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
188186

189187
var fixedCode = @"namespace FooNamespace
190188
{{

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,17 @@ public async Task TestCodeFixAsync(int codepage)
8686
Location.Create(await document.GetSyntaxTreeAsync().ConfigureAwait(false), TextSpan.FromBounds(0, 0)),
8787
properties);
8888

89-
await codeFixer.RegisterCodeFixesAsync(new CodeFixContext(document, diagnostic, (ca, d) =>
90-
{
91-
var operation = ca.GetOperationsAsync(CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()[0];
92-
93-
operation.Apply(workspace, CancellationToken.None);
94-
}, CancellationToken.None)).ConfigureAwait(false);
89+
await codeFixer.RegisterCodeFixesAsync(
90+
new CodeFixContext(
91+
document,
92+
diagnostic,
93+
(ca, d) =>
94+
{
95+
var operation = ca.GetOperationsAsync(CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()[0];
96+
97+
operation.Apply(workspace, CancellationToken.None);
98+
},
99+
CancellationToken.None)).ConfigureAwait(false);
95100

96101
// project should now have the "fixed document" in it.
97102
// Because of limitations in Roslyn the fixed document should

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CodeFixVerifier.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,17 @@ private static bool AreDiagnosticsDifferent(ImmutableArray<Diagnostic> analyzerD
293293
return false;
294294
}
295295

296-
private async Task VerifyFixInternalAsync(string language, ImmutableArray<DiagnosticAnalyzer> analyzers, CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex,
297-
bool allowNewCompilerDiagnostics, int maxNumberOfIterations, Func<ImmutableArray<DiagnosticAnalyzer>, CodeFixProvider, int?, Document, int, CancellationToken, Task<Document>> getFixedDocument, CancellationToken cancellationToken)
296+
private async Task VerifyFixInternalAsync(
297+
string language,
298+
ImmutableArray<DiagnosticAnalyzer> analyzers,
299+
CodeFixProvider codeFixProvider,
300+
string oldSource,
301+
string newSource,
302+
int? codeFixIndex,
303+
bool allowNewCompilerDiagnostics,
304+
int maxNumberOfIterations,
305+
Func<ImmutableArray<DiagnosticAnalyzer>, CodeFixProvider, int?, Document, int, CancellationToken, Task<Document>> getFixedDocument,
306+
CancellationToken cancellationToken)
298307
{
299308
var document = this.CreateDocument(oldSource, language);
300309
var compilerDiagnostics = await GetCompilerDiagnosticsAsync(document, cancellationToken).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifier.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
167167
string message =
168168
string.Format(
169169
"Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n",
170-
expected.Locations.Length - 1, additionalLocations.Length,
170+
expected.Locations.Length - 1,
171+
additionalLocations.Length,
171172
FormatDiagnostics(analyzers, actual));
172173
Assert.True(false, message);
173174
}
@@ -183,7 +184,9 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
183184
string message =
184185
string.Format(
185186
"Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
186-
expected.Id, actual.Id, FormatDiagnostics(analyzers, actual));
187+
expected.Id,
188+
actual.Id,
189+
FormatDiagnostics(analyzers, actual));
187190
Assert.True(false, message);
188191
}
189192

@@ -192,7 +195,9 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
192195
string message =
193196
string.Format(
194197
"Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
195-
expected.Severity, actual.Severity, FormatDiagnostics(analyzers, actual));
198+
expected.Severity,
199+
actual.Severity,
200+
FormatDiagnostics(analyzers, actual));
196201
Assert.True(false, message);
197202
}
198203

@@ -201,7 +206,9 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
201206
string message =
202207
string.Format(
203208
"Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
204-
expected.Message, actual.GetMessage(), FormatDiagnostics(analyzers, actual));
209+
expected.Message,
210+
actual.GetMessage(),
211+
FormatDiagnostics(analyzers, actual));
205212
Assert.True(false, message);
206213
}
207214
}
@@ -224,7 +231,9 @@ private static void VerifyDiagnosticLocation(ImmutableArray<DiagnosticAnalyzer>
224231
string message =
225232
string.Format(
226233
"Expected diagnostic to be in file \"{0}\" was actually in file \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
227-
expected.Path, actualSpan.Path, FormatDiagnostics(analyzers, diagnostic));
234+
expected.Path,
235+
actualSpan.Path,
236+
FormatDiagnostics(analyzers, diagnostic));
228237
Assert.True(
229238
actualSpan.Path == expected.Path || (actualSpan.Path != null && actualSpan.Path.Contains("Test0.") && expected.Path.Contains("Test.")),
230239
message);
@@ -239,7 +248,9 @@ private static void VerifyDiagnosticLocation(ImmutableArray<DiagnosticAnalyzer>
239248
string message2 =
240249
string.Format(
241250
"Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
242-
expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzers, diagnostic));
251+
expected.Line,
252+
actualLinePosition.Line + 1,
253+
FormatDiagnostics(analyzers, diagnostic));
243254
Assert.True(false, message2);
244255
}
245256
}
@@ -252,7 +263,9 @@ private static void VerifyDiagnosticLocation(ImmutableArray<DiagnosticAnalyzer>
252263
string message2 =
253264
string.Format(
254265
"Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n",
255-
expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzers, diagnostic));
266+
expected.Column,
267+
actualLinePosition.Character + 1,
268+
FormatDiagnostics(analyzers, diagnostic));
256269
Assert.True(false, message2);
257270
}
258271
}

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ private static void HandleElement(SyntaxNodeAnalysisContext context, XmlNodeSynt
116116
}
117117
else if (parentParameters.Length <= index || parentParameters[index] != nameAttribute.Identifier.Identifier.ValueText)
118118
{
119-
context.ReportDiagnostic(Diagnostic.Create(OrderDescriptor, nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
120-
nameAttribute.Identifier.Identifier.ValueText, parentParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
119+
context.ReportDiagnostic(
120+
Diagnostic.Create(
121+
OrderDescriptor,
122+
nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
123+
nameAttribute.Identifier.Identifier.ValueText,
124+
parentParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
121125
}
122126
}
123127

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1620GenericTypeParameterDocumentationMustMatchTypeParameters.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ private static void HandleElement(SyntaxNodeAnalysisContext context, XmlNodeSynt
117117
}
118118
else if (parentTypeParameters.Length <= index || parentTypeParameters[index] != nameAttribute.Identifier.Identifier.ValueText)
119119
{
120-
context.ReportDiagnostic(Diagnostic.Create(OrderDescriptor, nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
121-
nameAttribute.Identifier.Identifier.ValueText, parentTypeParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
120+
context.ReportDiagnostic(
121+
Diagnostic.Create(
122+
OrderDescriptor,
123+
nameAttribute?.Identifier?.GetLocation() ?? alternativeDiagnosticLocation,
124+
nameAttribute.Identifier.Identifier.ValueText,
125+
parentTypeParameters.IndexOf(nameAttribute.Identifier.Identifier.ValueText) + 1));
122126
}
123127
}
124128

StyleCop.Analyzers/StyleCop.Analyzers/Helpers/CustomBatchFixAllProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public async virtual Task AddDocumentFixesAsync(Document document, ImmutableArra
8383
fixerTasks[i] = Task.Run(async () =>
8484
{
8585
var localFixes = new List<CodeAction>();
86-
var context = new CodeFixContext(document, diagnostic,
86+
var context = new CodeFixContext(
87+
document,
88+
diagnostic,
8789
(a, d) =>
8890
{
8991
// TODO: Can we share code between similar lambdas that we pass to this API in BatchFixAllProvider.cs, CodeFixService.cs and CodeRefactoringService.cs?

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ internal class SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter : Diag
4040
private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1304.md";
4141

4242
private static readonly DiagnosticDescriptor Descriptor =
43-
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning,
44-
AnalyzerConstants.EnabledByDefault, Description, HelpLink);
43+
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink);
4544

4645
private static readonly ImmutableArray<DiagnosticDescriptor> SupportedDiagnosticsValue =
4746
ImmutableArray.Create(Descriptor);

StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,22 @@ public override void Initialize(AnalysisContext context)
8989

9090
private static void HandleCompilationStart(CompilationStartAnalysisContext context)
9191
{
92-
context.RegisterSyntaxNodeActionHonorExclusions(HandleDeclaration, SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration,
93-
SyntaxKind.EnumDeclaration, SyntaxKind.DelegateDeclaration, SyntaxKind.FieldDeclaration, SyntaxKind.MethodDeclaration,
94-
SyntaxKind.PropertyDeclaration, SyntaxKind.EventDeclaration, SyntaxKind.EventFieldDeclaration, SyntaxKind.IndexerDeclaration,
95-
SyntaxKind.OperatorDeclaration, SyntaxKind.ConversionOperatorDeclaration, SyntaxKind.ConstructorDeclaration);
92+
context.RegisterSyntaxNodeActionHonorExclusions(
93+
HandleDeclaration,
94+
SyntaxKind.ClassDeclaration,
95+
SyntaxKind.StructDeclaration,
96+
SyntaxKind.InterfaceDeclaration,
97+
SyntaxKind.EnumDeclaration,
98+
SyntaxKind.DelegateDeclaration,
99+
SyntaxKind.FieldDeclaration,
100+
SyntaxKind.MethodDeclaration,
101+
SyntaxKind.PropertyDeclaration,
102+
SyntaxKind.EventDeclaration,
103+
SyntaxKind.EventFieldDeclaration,
104+
SyntaxKind.IndexerDeclaration,
105+
SyntaxKind.OperatorDeclaration,
106+
SyntaxKind.ConversionOperatorDeclaration,
107+
SyntaxKind.ConstructorDeclaration);
96108
}
97109

98110
private static void HandleDeclaration(SyntaxNodeAnalysisContext context)

0 commit comments

Comments
 (0)