Skip to content

Commit f8e8c50

Browse files
Refactor analyzer method signatures for clarity
Refactored AnalyzeExpressionBody to take no parameters and updated all usages accordingly. Removed the unused context parameter from FindSubstringUsage and updated all call sites. These changes simplify method signatures and improve code clarity.
1 parent ee1cf23 commit f8e8c50

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Analyzers/IndexOfSubstringAnalyzer.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private static void AnalyzeMethod(SyntaxNodeAnalysisContext context)
2929
if (method.Body != null)
3030
AnalyzeBlock(context, method.Body.Statements);
3131
else if (method.ExpressionBody != null)
32-
AnalyzeExpressionBody(context, method.ExpressionBody);
32+
AnalyzeExpressionBody();
3333
}
3434

3535
private static void AnalyzeLocalFunction(SyntaxNodeAnalysisContext context)
@@ -38,7 +38,7 @@ private static void AnalyzeLocalFunction(SyntaxNodeAnalysisContext context)
3838
if (localFunction.Body != null)
3939
AnalyzeBlock(context, localFunction.Body.Statements);
4040
else if (localFunction.ExpressionBody != null)
41-
AnalyzeExpressionBody(context, localFunction.ExpressionBody);
41+
AnalyzeExpressionBody();
4242
}
4343

4444
private static void AnalyzeBlock(SyntaxNodeAnalysisContext context, SyntaxList<StatementSyntax> statements)
@@ -56,7 +56,7 @@ private static void AnalyzeBlock(SyntaxNodeAnalysisContext context, SyntaxList<S
5656
{
5757
// Look ahead for Substring call using this variable
5858
var variableName = variable.Identifier.Text;
59-
if (FindSubstringUsage(statements.Skip(i + 1), variableName, context, out var substringLocation))
59+
if (FindSubstringUsage(statements.Skip(i + 1), variableName, out var substringLocation))
6060
{
6161
var diagnostic = Diagnostic.Create(
6262
DiagnosticDescriptors.UseSpanForIndexOfSubstring,
@@ -76,7 +76,7 @@ assignment.Left is IdentifierNameSyntax identifier &&
7676
if (IsIndexOfCall(indexOfCall, context))
7777
{
7878
var variableName = identifier.Identifier.Text;
79-
if (FindSubstringUsage(statements.Skip(i + 1), variableName, context, out var substringLocation))
79+
if (FindSubstringUsage(statements.Skip(i + 1), variableName, out var substringLocation))
8080
{
8181
var diagnostic = Diagnostic.Create(
8282
DiagnosticDescriptors.UseSpanForIndexOfSubstring,
@@ -88,7 +88,7 @@ assignment.Left is IdentifierNameSyntax identifier &&
8888
}
8989
}
9090

91-
private static void AnalyzeExpressionBody(SyntaxNodeAnalysisContext context, ArrowExpressionClauseSyntax expressionBody)
91+
private static void AnalyzeExpressionBody()
9292
{
9393
// For expression-bodied members, we can check if there's a chained pattern
9494
// This is a simplified check for common patterns
@@ -114,7 +114,6 @@ private static bool IsIndexOfCall(InvocationExpressionSyntax invocation, SyntaxN
114114
private static bool FindSubstringUsage(
115115
System.Collections.Generic.IEnumerable<StatementSyntax> statements,
116116
string variableName,
117-
SyntaxNodeAnalysisContext context,
118117
out Location? location)
119118
{
120119
location = null;

0 commit comments

Comments
 (0)