File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Rubberduck.CodeAnalysis/Inspections/Concrete
RubberduckTests/Inspections Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
22
22
. Where ( declaration =>
23
23
! declaration . IsWithEvents
24
24
&& ! IsIgnoringInspectionResultFor ( declaration , AnnotationName )
25
- && declaration . References . All ( reference => reference . IsAssignment ) ) ;
25
+ && ! declaration . References . Any ( ) ) ;
26
26
27
27
return declarations . Select ( issue =>
28
28
new DeclarationInspectionResult ( this ,
Original file line number Diff line number Diff line change @@ -148,12 +148,24 @@ Dim var1 As String
148
148
149
149
[ Test ]
150
150
[ Category ( "Inspections" ) ]
151
- public void InspectionName ( )
151
+ public void VariableUsed_DoesNotReturnResultIfAssigned ( )
152
152
{
153
- const string inspectionName = "VariableNotUsedInspection" ;
154
- var inspection = new VariableNotUsedInspection ( null ) ;
153
+ const string inputCode =
154
+ @"Function Foo() As Boolean
155
+ Dim var1 as String
156
+ var1 = ""test""
157
+ End Function" ;
158
+
159
+ var vbe = MockVbeBuilder . BuildFromSingleStandardModule ( inputCode , out _ ) ;
160
+ using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
161
+ {
162
+
163
+ var inspection = new VariableNotUsedInspection ( state ) ;
164
+ var inspectionResults = inspection . GetInspectionResults ( CancellationToken . None ) ;
155
165
156
- Assert . AreEqual ( inspectionName , inspection . Name ) ;
166
+ Assert . AreEqual ( 0 , inspectionResults . Count ( ) ) ;
167
+ }
157
168
}
169
+
158
170
}
159
171
}
You can’t perform that action at this time.
0 commit comments