Skip to content

Commit

Permalink
Merge pull request #5185 from Vogel612/fix/ignore-underscore-inspection
Browse files Browse the repository at this point in the history
Fix Ignore and IgnoreModule for UnderscoreInPublicMemberName Inspection
  • Loading branch information
bclothier committed Oct 5, 2019
2 parents 8b4fe5a + 60e2dac commit 1701916
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
Expand Up @@ -5,6 +5,7 @@
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Resources.Inspections;
using Rubberduck.Parsing.VBA;
using Rubberduck.Inspections.Inspections.Extensions;

namespace Rubberduck.Inspections.Concrete
{
Expand Down Expand Up @@ -46,6 +47,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
.Where(w => !interfaceMembers.Contains(w) && !eventHandlers.Contains(w))
.Where(w => w.Accessibility == Parsing.Symbols.Accessibility.Public || w.Accessibility == Parsing.Symbols.Accessibility.Implicit)
.Where(w => w.IdentifierName.Contains('_'))
.Where(d => !d.IsIgnoringInspectionResultFor(AnnotationName))
.ToList();

return names.Select(issue =>
Expand Down
Expand Up @@ -8,10 +8,11 @@
namespace RubberduckTests.Inspections
{
[TestFixture]
[Category("Inspections")]
[Category("UnderscoreInPublicMember")]
public class UnderscoreInPublicClassModuleMemberInspectionTests
{
[Test]
[Category("Inspections")]
public void BasicExample_Sub()
{
const string inputCode =
Expand All @@ -29,7 +30,48 @@ public void BasicExample_Sub()
}

[Test]
[Category("Inspections")]
public void Basic_Ignored()
{
const string inputCode =
@"'@Ignore UnderscoreInPublicClassModuleMember
Public Sub This_Is_Ignored()
End Sub
Public Sub This_Should_Be_Marked()
End Sub";
var vbe = MockVbeBuilder.BuildFromSingleModule(inputCode, ComponentType.ClassModule, out _);
using (var state = MockParser.CreateAndParse(vbe.Object))
{
var inspection = new UnderscoreInPublicClassModuleMemberInspection(state);
var inspector = InspectionsHelper.GetInspector(inspection);
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

Assert.AreEqual(1, inspectionResults.Count());
}
}

[Test]
public void Basic_IgnoreModule()
{
const string inputCode =
@"'@IgnoreModule UnderscoreInPublicClassModuleMember
Public Sub This_Is_Ignored()
End Sub
Public Sub This_Is_Also_Ignored()
End Sub";
var vbe = MockVbeBuilder.BuildFromSingleModule(inputCode, ComponentType.ClassModule, out _);
using (var state = MockParser.CreateAndParse(vbe.Object))
{
var inspection = new UnderscoreInPublicClassModuleMemberInspection(state);
var inspector = InspectionsHelper.GetInspector(inspection);
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

Assert.AreEqual(0, inspectionResults.Count());
}
}

[Test]
public void BasicExample_Function()
{
const string inputCode =
Expand All @@ -47,7 +89,6 @@ public void BasicExample_Function()
}

[Test]
[Category("Inspections")]
public void BasicExample_Property()
{
const string inputCode =
Expand All @@ -65,7 +106,6 @@ public void BasicExample_Property()
}

[Test]
[Category("Inspections")]
public void StandardModule()
{
const string inputCode =
Expand All @@ -83,7 +123,6 @@ public void StandardModule()
}

[Test]
[Category("Inspections")]
public void NoUnderscore()
{
const string inputCode =
Expand All @@ -101,7 +140,6 @@ public void NoUnderscore()
}

[Test]
[Category("Inspections")]
public void FriendMember_WithUnderscore()
{
const string inputCode =
Expand All @@ -119,7 +157,6 @@ public void FriendMember_WithUnderscore()
}

[Test]
[Category("Inspections")]
public void Implicit_WithUnderscore()
{
const string inputCode =
Expand All @@ -137,7 +174,6 @@ public void Implicit_WithUnderscore()
}

[Test]
[Category("Inspections")]
public void ImplementsInterface()
{
const string inputCode1 =
Expand Down

0 comments on commit 1701916

Please sign in to comment.