Skip to content

Commit a59739a

Browse files
committed
Make the ModuleWithoutFolderAnnotationInspection honor IgnoreModule
1 parent 1d11646 commit a59739a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/ModuleWithoutFolderInspection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ public sealed class ModuleWithoutFolderInspection : InspectionBase
1313
{
1414
public ModuleWithoutFolderInspection(RubberduckParserState state)
1515
: base(state)
16-
{
17-
}
16+
{}
1817

1918
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2019
{
2120
var modulesWithoutFolderAnnotation = State.DeclarationFinder.UserDeclarations(Parsing.Symbols.DeclarationType.Module)
2221
.Where(w => w.Annotations.All(a => a.AnnotationType != AnnotationType.Folder))
2322
.ToList();
2423

25-
return modulesWithoutFolderAnnotation.Select(declaration =>
24+
return modulesWithoutFolderAnnotation
25+
.Where(declaration => !IsIgnoringInspectionResultFor(declaration, AnnotationName))
26+
.Select(declaration =>
2627
new DeclarationInspectionResult(this, string.Format(InspectionResults.ModuleWithoutFolderInspection, declaration.IdentifierName), declaration));
2728
}
2829
}

RubberduckTests/Inspections/ModuleWithoutFolderInspectionTests.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void Module_FolderAnnotation()
4646
[Category("Inspections")]
4747
public void Module_NonFolderAnnotation()
4848
{
49-
const string inputCode = @"'@IgnoreModule
49+
const string inputCode = @"'@PredeclaredId
5050
Option Explicit";
5151

5252
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
@@ -58,5 +58,22 @@ public void Module_NonFolderAnnotation()
5858
Assert.AreEqual(1, inspectionResults.Count());
5959
}
6060
}
61+
62+
[Test]
63+
[Category("Inspections")]
64+
public void Module_NoFolderAnnotation_IgnoreWorks()
65+
{
66+
const string inputCode = @"'@IgnoreModule ModuleWithoutFolder
67+
Option Explicit";
68+
69+
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
70+
using (var state = MockParser.CreateAndParse(vbe.Object))
71+
{
72+
var inspection = new ModuleWithoutFolderInspection(state);
73+
var inspectionResults = inspection.GetInspectionResults(CancellationToken.None);
74+
75+
Assert.IsFalse(inspectionResults.Any());
76+
}
77+
}
6178
}
6279
}

0 commit comments

Comments
 (0)