-
Notifications
You must be signed in to change notification settings - Fork 238
Replace calls to obsolete SonarTreeReportingContextBase.ReportIssue overload #9377
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
Replace calls to obsolete SonarTreeReportingContextBase.ReportIssue overload #9377
Conversation
pavel-mikula-sonarsource
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| if (typeSyntax != null && typeSyntax.IsKnownType(KnownType.System_Collections_Generic_List_T, context.SemanticModel)) | ||
| { | ||
| context.ReportIssue(Diagnostic.Create(Rule, typeSyntax.GetLocation(), messageArgs: memberType)); | ||
| context.ReportIssue(Rule, typeSyntax, messageArgs: memberType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can go away
| context.ReportIssue(Rule, typeSyntax, messageArgs: memberType); | |
| context.ReportIssue(Rule, typeSyntax, memberType); |
| c.ReportIssue(Rule, forNode.Condition, | ||
| string.Format(CultureInfo.InvariantCulture, MessageFormatNotEmpty, conditionVariables, incrementedVariables)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fit in a single line. Same below in the else.
| analysisContext.ReportIssue(Rule, | ||
| identifierName, | ||
| declaration.Identifier.ValueText, | ||
| string.Concat(explicitInterfaceSpecifier.Name, ".", identifierName.ValueText)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace: The Rule should be on the next line. Or everything should be on a single line if it fits into 200 chars
| forEachStatementSyntax.Expression.GetLocation(), | ||
| string.Format(SelectMessageFormat, forEachStatementSyntax.Identifier.ValueText, accessedProperties.Single().Key.Name)); | ||
| c.ReportIssue(diagnostic); | ||
| c.ReportIssue(Rule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, Rule on the next line, or all in a single line
| Rule, | ||
| candidate.Locations.FirstOrDefault(), | ||
| messageArgs: candidate.Name)); | ||
| messageArgs: candidate.Name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can go away. And as you'll open the file, the invocation can be a single line
| messageArgs: candidate.Name); | |
| candidate.Name); |
| private static void Report(SonarSyntaxNodeReportingContext c, VariableDeclaratorSyntax declaratorSyntax) => | ||
| c.ReportIssue(Diagnostic.Create(Rule, | ||
| declaratorSyntax.Identifier.GetLocation(), | ||
| c.ReportIssue(Rule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here
| && IsConstantEmptyString(firstArgument.Expression, c.SemanticModel)) | ||
| { | ||
| c.ReportIssue(Diagnostic.Create(rule, invocationExpression.GetLocation(), MessageFormat)); | ||
| c.ReportIssue(rule, invocationExpression.GetLocation(), MessageFormat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| c.ReportIssue(rule, invocationExpression.GetLocation(), MessageFormat); | |
| c.ReportIssue(rule, invocationExpression, MessageFormat); |
| action, | ||
| exportedType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat), | ||
| attributeTargetType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat))); | ||
| c.ReportIssue(Rule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule on the next line
| @@ -54,10 +54,10 @@ public override void VisitIdentifierName(IdentifierNameSyntax node) | |||
| { | |||
| if (IsImplicitReturnValue(node)) | |||
| { | |||
| context.ReportIssue(Diagnostic.Create(Rule, node.GetLocation(), | |||
| context.ReportIssue(Rule, node, | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the formatting on this tone. Single line should do the trick . Otherwise, Rule and node would need separate lines, while the ternary should be on a single line
| @@ -107,8 +107,8 @@ private bool CheckExpression(SonarSyntaxNodeReportingContext context, Expression | |||
| if (matchCount >= MinimumSeriesLength) | |||
| { | |||
| var nextStatementCount = matchCount - 1; | |||
| context.ReportIssue(Diagnostic.Create(rule, executableStatement.GetLocation(), | |||
| nextStatementCount, expression.ToString(), nextStatementCount == 1 ? string.Empty : "s")); | |||
| context.ReportIssue(rule, executableStatement, | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
This reverts commit 0ec893a.
b728718 to
f42f868
Compare
|
|




Follow up on #9298 and others
The PR replaces all simple cases of calls to
sonar-dotnet/analyzers/src/SonarAnalyzer.Common/AnalysisContext/SonarReportingContextBase.cs
Lines 93 to 95 in 4ffbdc6