Skip to content

Commit 9d53d8d

Browse files
author
Kapil Borle
committed
Examine only the last word in noun part of function name
1 parent dc89366 commit 9d53d8d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Rules/UseSingularNouns.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
5252
if (funcAst.Name != null && funcAst.Name.Contains('-'))
5353
{
5454
funcNamePieces = funcAst.Name.Split(funcSeperator);
55-
String noun = funcNamePieces[1];
55+
String nounPart = funcNamePieces[1];
5656

5757
// Convert the noun part of the function into a series of space delimited words
5858
// This helps the PluralizationService to provide an accurate determination about the plurality of the string
59-
noun = SplitCamelCaseString(noun);
60-
59+
nounPart = SplitCamelCaseString(nounPart);
60+
var words = nounPart.Split(new char [] { ' ' });
61+
var noun = words.LastOrDefault();
62+
if (noun == null)
63+
{
64+
continue;
65+
}
6166
var ps = System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us"));
6267

6368
if (!ps.IsSingular(noun) && ps.IsPlural(noun))

0 commit comments

Comments
 (0)