Skip to content

Commit d178170

Browse files
committed
Added forgotten check for ignore annotation.
1 parent ce18bea commit d178170

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Rubberduck.CodeAnalysis/Inspections/Abstract/MemberAccessMayReturnNothingInspectionBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2828
}
2929

3030
var output = new List<IInspectionResult>();
31-
foreach (var reference in interesting)
31+
foreach (var reference in interesting.Where(use => !IsIgnoringInspectionResultFor(use, AnnotationName)))
3232
{
3333
var access = reference.Context.GetAncestor<VBAParser.MemberAccessExprContext>();
3434
var usageContext = access.Parent is VBAParser.IndexExprContext

RubberduckTests/Inspections/ExcelMemberMayReturnNothingInspectionTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ End Sub
3333
}
3434
}
3535

36+
[Test]
37+
[Category("Inspections")]
38+
public void ExcelMemberMayReturnNothing_Ignored_DoesNotReturnResult()
39+
{
40+
const string inputCode =
41+
@"Sub UnderTest()
42+
Dim ws As Worksheet
43+
Set ws = Sheet1
44+
'@Ignore ExcelMemberMayReturnNothing
45+
foo = ws.UsedRange.Find(""foo"").Row
46+
End Sub
47+
";
48+
49+
using (var state = ArrangeParserAndParse(inputCode))
50+
{
51+
52+
var inspection = new ExcelMemberMayReturnNothingInspection(state);
53+
var inspectionResults = inspection.GetInspectionResults(CancellationToken.None);
54+
55+
Assert.IsFalse(inspectionResults.Any());
56+
}
57+
}
58+
3659
[Test]
3760
[Category("Inspections")]
3861
public void ExcelMemberMayReturnNothing_ReturnsNoResult_ResultIsNothingInAssignment()

0 commit comments

Comments
 (0)