Skip to content

Commit 5e71bf3

Browse files
committed
Fix correction
1 parent 025d9a4 commit 5e71bf3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Rules/UseSingularNouns.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
8888
GetName(),
8989
DiagnosticSeverity.Warning,
9090
fileName,
91-
suggestedCorrections: new CorrectionExtent[] { GetCorrection(pluralizer, extent, noun) });
91+
suggestedCorrections: new CorrectionExtent[] { GetCorrection(pluralizer, extent, funcAst.Name, noun) });
9292
}
9393
}
9494

@@ -146,10 +146,11 @@ public string GetSourceName()
146146
return string.Format(CultureInfo.CurrentCulture, Strings.SourceName);
147147
}
148148

149-
private CorrectionExtent GetCorrection(PluralizerProxy pluralizer, IScriptExtent extent, string noun)
149+
private CorrectionExtent GetCorrection(PluralizerProxy pluralizer, IScriptExtent extent, string commandName, string noun)
150150
{
151151
string singularNoun = pluralizer.Singularize(noun);
152-
return new CorrectionExtent(extent, singularNoun, extent.File, $"Singularized correction of '{extent.Text}'");
152+
string newCommandName = commandName.Substring(0, commandName.Length - noun.Length) + singularNoun;
153+
return new CorrectionExtent(extent, newCommandName, extent.File, $"Singularized correction of '{extent.Text}'");
153154
}
154155

155156
/// <summary>

0 commit comments

Comments
 (0)