Skip to content

Commit 174c737

Browse files
committed
Closes #1196
1 parent 29b27ea commit 174c737

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

RetailCoder.VBE/Inspections/UseMeaningfulNameInspection.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using Rubberduck.Parsing.Symbols;
45
using Rubberduck.Parsing.VBA;
@@ -25,10 +26,11 @@ public UseMeaningfulNameInspection(IMessageBox messageBox, RubberduckParserState
2526
public override IEnumerable<InspectionResultBase> GetInspectionResults()
2627
{
2728
var issues = UserDeclarations
28-
.Where(declaration => declaration.DeclarationType != DeclarationType.ModuleOption &&
29+
.Where(declaration => declaration.DeclarationType != DeclarationType.ModuleOption &&
2930
(declaration.IdentifierName.Length < 3 ||
3031
char.IsDigit(declaration.IdentifierName.Last()) ||
31-
!declaration.IdentifierName.Any(c => new[] {'a', 'e', 'i', 'o', 'u', 'y'}.Contains(c))))
32+
!declaration.IdentifierName.Any(c =>
33+
"aeiouy".Any(a => string.Compare(a.ToString(), c.ToString(), StringComparison.OrdinalIgnoreCase) == 0))))
3234
.Select(issue => new UseMeaningfulNameInspectionResult(this, issue, State, _wrapperFactory, _messageBox))
3335
.ToList();
3436

RubberduckTests/Inspections/UseMeaningfulNameInspectionTests.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void UseMeaningfulName_ReturnsResult_NameEndsWithDigit()
9494
}
9595

9696
[TestMethod]
97-
public void UseMeaningfulName_DoesNotReturnsResult_GoodName()
97+
public void UseMeaningfulName_DoesNotReturnsResult_GoodName_LowerCaseVowels()
9898
{
9999
const string inputCode =
100100
@"Sub FooBar()
@@ -120,6 +120,33 @@ public void UseMeaningfulName_DoesNotReturnsResult_GoodName()
120120
Assert.AreEqual(0, inspectionResults.Count());
121121
}
122122

123+
[TestMethod]
124+
public void UseMeaningfulName_DoesNotReturnsResult_GoodName_UpperCaseVowels()
125+
{
126+
const string inputCode =
127+
@"Sub FOOBAR()
128+
End Sub";
129+
130+
//Arrange
131+
var builder = new MockVbeBuilder();
132+
var project = builder.ProjectBuilder("VBAProject", vbext_ProjectProtection.vbext_pp_none)
133+
.AddComponent("MyClass", vbext_ComponentType.vbext_ct_ClassModule, inputCode)
134+
.Build();
135+
var vbe = builder.AddProject(project).Build();
136+
137+
var mockHost = new Mock<IHostApplication>();
138+
mockHost.SetupAllProperties();
139+
var parser = MockParser.Create(vbe.Object, new RubberduckParserState());
140+
141+
parser.Parse();
142+
if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); }
143+
144+
var inspection = new UseMeaningfulNameInspection(null, parser.State);
145+
var inspectionResults = inspection.GetInspectionResults();
146+
147+
Assert.AreEqual(0, inspectionResults.Count());
148+
}
149+
123150
[TestMethod]
124151
public void UseMeaningfulName_DoesNotReturnsResult_OptionBase()
125152
{

0 commit comments

Comments
 (0)