@@ -278,12 +278,16 @@ func TestNolintUnused(t *testing.T) {
278
278
279
279
createProcessor := func (t * testing.T , log * logutils.MockLog , enabledLinters []string ) * Nolint {
280
280
enabledSetLog := logutils .NewMockLog ()
281
- enabledSetLog .On ("Infof" , "Active %d linters: %s" , len (enabledLinters ), enabledLinters )
281
+ enabledSetLog .On ("Infof" , "Active %d linters: %s" , len (enabledLinters ), enabledLinters ).Once ()
282
+
282
283
cfg := & config.Config {Linters : config.Linters {DisableAll : true , Enable : enabledLinters }}
283
284
dbManager := lintersdb .NewManager (cfg , nil )
285
+
284
286
enabledLintersSet := lintersdb .NewEnabledSet (dbManager , lintersdb .NewValidator (dbManager ), enabledSetLog , cfg )
287
+
285
288
enabledLintersMap , err := enabledLintersSet .GetEnabledLintersMap ()
286
289
assert .NoError (t , err )
290
+
287
291
return NewNolint (log , dbManager , enabledLintersMap )
288
292
}
289
293
@@ -310,21 +314,21 @@ func TestNolintUnused(t *testing.T) {
310
314
}
311
315
312
316
t .Run ("when an issue does not occur, it is not removed from the nolintlint issues" , func (t * testing.T ) {
313
- p := createProcessor (t , log , []string {"nolintlint" , "typecheck" , " varcheck" })
317
+ p := createProcessor (t , log , []string {"nolintlint" , "varcheck" })
314
318
defer p .Finish ()
315
319
316
320
processAssertSame (t , p , nolintlintIssueVarcheck )
317
321
})
318
322
319
323
t .Run ("when an issue does not occur but nolintlint is nolinted, it is removed from the nolintlint issues" , func (t * testing.T ) {
320
- p := createProcessor (t , log , []string {"nolintlint" , "typecheck" , " varcheck" })
324
+ p := createProcessor (t , log , []string {"nolintlint" , "varcheck" })
321
325
defer p .Finish ()
322
326
323
327
processAssertEmpty (t , p , nolintlintIssueVarcheckUnusedOK )
324
328
})
325
329
326
330
t .Run ("when an issue occurs, it is removed from the nolintlint issues" , func (t * testing.T ) {
327
- p := createProcessor (t , log , []string {"nolintlint" , "typecheck" , " varcheck" })
331
+ p := createProcessor (t , log , []string {"nolintlint" , "varcheck" })
328
332
defer p .Finish ()
329
333
330
334
processAssertEmpty (t , p , []result.Issue {{
@@ -338,7 +342,7 @@ func TestNolintUnused(t *testing.T) {
338
342
339
343
t .Run ("when a linter is not enabled, it is removed from the nolintlint unused issues" , func (t * testing.T ) {
340
344
enabledSetLog := logutils .NewMockLog ()
341
- enabledSetLog .On ("Infof" , "Active %d linters: %s" , 2 , []string {"nolintlint" , "typecheck " })
345
+ enabledSetLog .On ("Infof" , "Active %d linters: %s" , 1 , []string {"nolintlint" })
342
346
343
347
cfg := & config.Config {Linters : config.Linters {DisableAll : true , Enable : []string {"nolintlint" }}}
344
348
dbManager := lintersdb .NewManager (cfg , nil )
0 commit comments