diff --git a/Rubberduck.CodeAnalysis/Inspections/Concrete/UnderscoreInPublicClassModuleMemberInspection.cs b/Rubberduck.CodeAnalysis/Inspections/Concrete/UnderscoreInPublicClassModuleMemberInspection.cs index 06e9c222ef..38a9f81e84 100644 --- a/Rubberduck.CodeAnalysis/Inspections/Concrete/UnderscoreInPublicClassModuleMemberInspection.cs +++ b/Rubberduck.CodeAnalysis/Inspections/Concrete/UnderscoreInPublicClassModuleMemberInspection.cs @@ -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 { @@ -46,6 +47,7 @@ protected override IEnumerable 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 => diff --git a/RubberduckTests/Inspections/UnderscoreInPublicClassModuleMemberInspectionTests.cs b/RubberduckTests/Inspections/UnderscoreInPublicClassModuleMemberInspectionTests.cs index 99e7ac0b1c..3cd6f51fe2 100644 --- a/RubberduckTests/Inspections/UnderscoreInPublicClassModuleMemberInspectionTests.cs +++ b/RubberduckTests/Inspections/UnderscoreInPublicClassModuleMemberInspectionTests.cs @@ -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 = @@ -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 = @@ -47,7 +89,6 @@ public void BasicExample_Function() } [Test] - [Category("Inspections")] public void BasicExample_Property() { const string inputCode = @@ -65,7 +106,6 @@ public void BasicExample_Property() } [Test] - [Category("Inspections")] public void StandardModule() { const string inputCode = @@ -83,7 +123,6 @@ public void StandardModule() } [Test] - [Category("Inspections")] public void NoUnderscore() { const string inputCode = @@ -101,7 +140,6 @@ public void NoUnderscore() } [Test] - [Category("Inspections")] public void FriendMember_WithUnderscore() { const string inputCode = @@ -119,7 +157,6 @@ public void FriendMember_WithUnderscore() } [Test] - [Category("Inspections")] public void Implicit_WithUnderscore() { const string inputCode = @@ -137,7 +174,6 @@ public void Implicit_WithUnderscore() } [Test] - [Category("Inspections")] public void ImplementsInterface() { const string inputCode1 =