10
10
namespace RubberduckTests . Inspections
11
11
{
12
12
[ TestFixture ]
13
+ [ Category ( "Inspections" ) ]
14
+ [ Category ( "AssignmentNotUsed" ) ]
13
15
public class AssignmentNotUsedInspectionTests
14
16
{
15
17
private IEnumerable < IInspectionResult > GetInspectionResults ( string code , bool includeLibraries = false )
@@ -25,7 +27,6 @@ private IEnumerable<IInspectionResult> GetInspectionResults(string code, bool in
25
27
}
26
28
27
29
[ Test ]
28
- [ Category ( "Inspections" ) ]
29
30
public void IgnoresExplicitArrays ( )
30
31
{
31
32
const string code = @"
@@ -39,7 +40,6 @@ End Sub
39
40
}
40
41
41
42
[ Test ]
42
- [ Category ( "Inspections" ) ]
43
43
public void IgnoresImplicitArrays ( )
44
44
{
45
45
const string code = @"
@@ -54,7 +54,6 @@ End Sub
54
54
}
55
55
56
56
[ Test ]
57
- [ Category ( "Inspections" ) ]
58
57
public void IgnoresImplicitReDimmedArray ( )
59
58
{
60
59
const string code = @"
@@ -69,7 +68,6 @@ End Sub
69
68
}
70
69
71
70
[ Test ]
72
- [ Category ( "Inspections" ) ]
73
71
public void MarksSequentialAssignments ( )
74
72
{
75
73
const string code = @"
@@ -87,7 +85,6 @@ Sub Bar(ByVal i As Integer)
87
85
}
88
86
89
87
[ Test ]
90
- [ Category ( "Inspections" ) ]
91
88
public void MarksLastAssignmentInDeclarationBlock ( )
92
89
{
93
90
const string code = @"
@@ -100,7 +97,6 @@ Dim i As Integer
100
97
}
101
98
102
99
[ Test ]
103
- [ Category ( "Inspections" ) ]
104
100
// Note: both assignments in the if/else can be marked in the future;
105
101
// I just want feedback before I start mucking around that deep.
106
102
public void DoesNotMarkLastAssignmentInNonDeclarationBlock ( )
@@ -120,7 +116,6 @@ End If
120
116
}
121
117
122
118
[ Test ]
123
- [ Category ( "Inspections" ) ]
124
119
public void DoesNotMarkAssignmentWithReferenceAfter ( )
125
120
{
126
121
const string code = @"
@@ -137,7 +132,6 @@ Sub Bar(ByVal i As Integer)
137
132
}
138
133
139
134
[ Test ]
140
- [ Category ( "Inspections" ) ]
141
135
public void DoesNotMarkAssignment_UsedInForNext ( )
142
136
{
143
137
const string code = @"
@@ -152,7 +146,6 @@ Dim i As Integer
152
146
}
153
147
154
148
[ Test ]
155
- [ Category ( "Inspections" ) ]
156
149
public void DoesNotMarkAssignment_UsedInWhileWend ( )
157
150
{
158
151
const string code = @"
@@ -169,7 +162,6 @@ While i < 10
169
162
}
170
163
171
164
[ Test ]
172
- [ Category ( "Inspections" ) ]
173
165
public void DoesNotMarkAssignment_UsedInDoWhile ( )
174
166
{
175
167
const string code = @"
@@ -184,7 +176,6 @@ Do While i < 10
184
176
}
185
177
186
178
[ Test ]
187
- [ Category ( "Inspections" ) ]
188
179
public void DoesNotMarkAssignment_UsedInSelectCase ( )
189
180
{
190
181
const string code = @"
@@ -207,7 +198,6 @@ End Select
207
198
}
208
199
209
200
[ Test ]
210
- [ Category ( "Inspections" ) ]
211
201
public void DoesNotMarkAssignment_UsingNothing ( )
212
202
{
213
203
const string code = @"
@@ -224,7 +214,6 @@ Debug.Print my_fso.GetFolder(""C:\Windows"").DateLastModified
224
214
}
225
215
226
216
[ Test ]
227
- [ Category ( "Inspections" ) ]
228
217
public void DoesMarkAssignment_UsingNothing_NotUsed ( )
229
218
{
230
219
const string code = @"
@@ -237,5 +226,43 @@ Dim my_fso As Scripting.FileSystemObject
237
226
var results = GetInspectionResults ( code , includeLibraries : true ) ;
238
227
Assert . AreEqual ( 1 , results . Count ( ) ) ;
239
228
}
229
+
230
+ [ Test ]
231
+ public void DoesNotMarkResults_InIgnoredModule ( )
232
+ {
233
+ const string code = @"'@IgnoreModule
234
+ Public Sub Test()
235
+ Dim foo As Long
236
+ foo = 1245316
237
+ End Sub" ;
238
+ var results = GetInspectionResults ( code , includeLibraries : false ) ;
239
+ Assert . AreEqual ( 0 , results . Count ( ) ) ;
240
+ }
241
+
242
+ [ Test ]
243
+ public void DoesNotMarkAssignment_WithIgnoreOnceAnnotation ( )
244
+ {
245
+ const string code = @"Public Sub Test()
246
+ Dim foo As Long
247
+ '@Ignore AssignmentNotUsed
248
+ foo = 123451
249
+ foo = 56126
250
+ End Sub" ;
251
+ var results = GetInspectionResults ( code , includeLibraries : false ) ;
252
+ Assert . AreEqual ( 1 , results . Count ( ) ) ;
253
+ }
254
+
255
+ [ Test ]
256
+ public void DoesNotMarkAssignment_ToIgnoredDeclaration ( )
257
+ {
258
+ const string code = @"Public Sub Test()
259
+ '@Ignore AssignmentNotUsed
260
+ Dim foo As Long
261
+ foo = 123467
262
+ foo = 45678
263
+ End Sub" ;
264
+ var results = GetInspectionResults ( code , includeLibraries : false ) ;
265
+ Assert . AreEqual ( 0 , results . Count ( ) ) ;
266
+ }
240
267
}
241
268
}
0 commit comments