Fix S1144 FN: Unused local functions#9071
Fix S1144 FN: Unused local functions#9071cristian-ambrosini-sonarsource merged 4 commits intomasterfrom
Conversation
| public static SyntaxToken? GetIdentifierOrDefault(this BaseMethodDeclarationSyntax methodDeclaration) | ||
| { | ||
| switch (methodDeclaration?.Kind()) | ||
| public static SyntaxToken? GetIdentifierOrDefault(this BaseMethodDeclarationSyntax methodDeclaration) => |
There was a problem hiding this comment.
Not strictly related to unused local functions, but requested in the same ticket.
Tim-Pohlmann
left a comment
There was a problem hiding this comment.
LGTM! Nitpicks only
analyzers/src/SonarAnalyzer.CSharp/Helpers/CSharpSyntaxHelper.cs
Outdated
Show resolved
Hide resolved
| SyntaxKind.ConstructorDeclaration => ((ConstructorDeclarationSyntax)methodDeclaration)?.Identifier, | ||
| SyntaxKind.DestructorDeclaration => ((DestructorDeclarationSyntax)methodDeclaration)?.Identifier, | ||
| SyntaxKind.MethodDeclaration => ((MethodDeclarationSyntax)methodDeclaration)?.Identifier, | ||
| _ when LocalFunctionStatementSyntaxWrapper.IsInstance(methodDeclaration) => ((LocalFunctionStatementSyntaxWrapper)methodDeclaration).Identifier, |
There was a problem hiding this comment.
This should follow the same pattern as the cases above using SyntaxKindEx.LocalFunctionStatement.
There was a problem hiding this comment.
We cannot cast to LocalFunctionStatementSyntax because we don't have it, so it would be something like:
SyntaxKindEx.LocalFunctionStatement => ((LocalFunctionStatementSyntaxWrapper)methodDeclaration).Identifier,
I'm not a fan of it, I prefer using LocalFunctionStatementSyntaxWrapper.IsInstance to reduce the assumptions.
There was a problem hiding this comment.
But it's the same assumption as in the three cases above.
analyzers/src/SonarAnalyzer.CSharp/Rules/UnusedPrivateMember.cs
Outdated
Show resolved
Hide resolved
|
Coverage seems low despite the gate being green. Please try to increase it before merging. |
|
|




Fixes #6699