Skip to content

Commit 70b53ca

Browse files
committed
Ignore interface implementations
1 parent 6d554ae commit 70b53ca

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/UnderscoreInPublicClassModuleMemberInspection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
1717
{
1818
var names = State.DeclarationFinder.UserDeclarations(Parsing.Symbols.DeclarationType.Member)
1919
.Where(w => w.ParentDeclaration.DeclarationType == Parsing.Symbols.DeclarationType.ClassModule)
20+
.Where(w => !State.DeclarationFinder.FindAllInterfaceImplementingMembers().Contains(w))
2021
.Where(w => w.Accessibility == Parsing.Symbols.Accessibility.Public)
2122
.Where(w => w.IdentifierName.Contains('_'))
2223
.ToList();

RubberduckTests/Inspections/UnderscoreInPublicClassModuleMemberInspectionTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,37 @@ public void Implicit_WithUnderscore()
135135
Assert.AreEqual(0, inspectionResults.Count());
136136
}
137137
}
138+
139+
[Test]
140+
[Category("Inspections")]
141+
public void ImplementsInterface()
142+
{
143+
const string inputCode1 =
144+
@"Public Sub Foo()
145+
End Sub";
146+
147+
//Expectation
148+
const string inputCode2 =
149+
@"Implements Class1
150+
151+
Public Sub Class1_Foo()
152+
Err.Raise 5 'TODO implement interface member
153+
End Sub
154+
";
155+
var builder = new MockVbeBuilder();
156+
var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected)
157+
.AddComponent("Class1", ComponentType.ClassModule, inputCode1)
158+
.AddComponent("Class2", ComponentType.ClassModule, inputCode2)
159+
.Build();
160+
var vbe = builder.AddProject(project).Build();
161+
using (var state = MockParser.CreateAndParse(vbe.Object))
162+
{
163+
var inspection = new UnderscoreInPublicClassModuleMemberInspection(state);
164+
var inspector = InspectionsHelper.GetInspector(inspection);
165+
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
166+
167+
Assert.AreEqual(0, inspectionResults.Count());
168+
}
169+
}
138170
}
139171
}

0 commit comments

Comments
 (0)