-
Notifications
You must be signed in to change notification settings - Fork 229
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 S2368 FP/FN: Don't raise for extension methods and raise for constructors #8152
Fix S2368 FP/FN: Don't raise for extension methods and raise for constructors #8152
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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
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.
Let's try to bump a bit the coverage to reach >95%
|
||
protected override SyntaxToken GetIdentifier(MethodStatementSyntax method) => method.Identifier; | ||
protected override Location GetIssueLocation(SyntaxNode node) => | ||
node?.RemoveParentheses() switch |
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.
Here you are passing c.Node
to the method which should be not null by design, so ?
can be removed
|
||
protected override SyntaxToken GetIdentifier(MethodStatementSyntax method) => method.Identifier; | ||
protected override Location GetIssueLocation(SyntaxNode node) => | ||
node?.RemoveParentheses() switch |
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 for RemoveParentheses()
, we are passing a MethodDeclaration
or a ConstructorDeclaration
so most probably it's not needed and can be removed
protected override Location GetIssueLocation(SyntaxNode node) => | ||
node?.RemoveParentheses() switch | ||
{ | ||
ConstructorBlockSyntax x => x.SubNewStatement.NewKeyword.GetLocation(), |
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 logic could be also rewritten as a ternary, something similar to:
protected override Location GetIssueLocation(SyntaxNode node) =>
node is ConstructorBlockSyntax x
? x.SubNewStatement.NewKeyword.GetLocation()
: Language.Syntax.NodeIdentifier(node)?.GetLocation();
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
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
5bf048e
into
SonarSource:master
Fixes #7329
And handles ordinary constructor support from #8083