@@ -75,7 +75,7 @@ func NewRunner(astCache *astcache.Cache, cfg *config.Config, log logutils.Log, g
75
75
skipDirsProcessor , // must be after path prettifier
76
76
77
77
processors .NewAutogeneratedExclude (astCache ),
78
- processors .NewIdentifierMarker (), // must be befor exclude
78
+ processors .NewIdentifierMarker (), // must be before exclude because users see already marked output and configure excluding by it
79
79
processors .NewExclude (excludeTotalPattern ),
80
80
processors .NewExcludeRules (excludeRules , lineCache , log .Child ("exclude_rules" )),
81
81
processors .NewNolint (astCache , log .Child ("nolint" ), dbManager ),
@@ -92,6 +92,8 @@ func NewRunner(astCache *astcache.Cache, cfg *config.Config, log logutils.Log, g
92
92
}, nil
93
93
}
94
94
95
+ func someUnusedFunc () {}
96
+
95
97
type lintRes struct {
96
98
linter * linter.Config
97
99
err error
@@ -217,13 +219,19 @@ func (r *Runner) runWorkers(ctx context.Context, lintCtx *linter.Context, linter
217
219
return lintResultsCh
218
220
}
219
221
222
+ type processorStat struct {
223
+ inCount int
224
+ outCount int
225
+ }
226
+
220
227
func (r Runner ) processLintResults (inCh <- chan lintRes ) <- chan lintRes {
221
228
outCh := make (chan lintRes , 64 )
222
229
223
230
go func () {
224
231
sw := timeutils .NewStopwatch ("processing" , r .Log )
225
232
226
233
var issuesBefore , issuesAfter int
234
+ statPerProcessor := map [string ]processorStat {}
227
235
defer close (outCh )
228
236
229
237
for res := range inCh {
@@ -234,7 +242,7 @@ func (r Runner) processLintResults(inCh <-chan lintRes) <-chan lintRes {
234
242
235
243
if len (res .issues ) != 0 {
236
244
issuesBefore += len (res .issues )
237
- res .issues = r .processIssues (res .issues , sw )
245
+ res .issues = r .processIssues (res .issues , sw , statPerProcessor )
238
246
issuesAfter += len (res .issues )
239
247
outCh <- res
240
248
}
@@ -252,12 +260,23 @@ func (r Runner) processLintResults(inCh <-chan lintRes) <-chan lintRes {
252
260
if issuesBefore != issuesAfter {
253
261
r .Log .Infof ("Issues before processing: %d, after processing: %d" , issuesBefore , issuesAfter )
254
262
}
263
+ r .printPerProcessorStat (statPerProcessor )
255
264
sw .PrintStages ()
256
265
}()
257
266
258
267
return outCh
259
268
}
260
269
270
+ func (r Runner ) printPerProcessorStat (stat map [string ]processorStat ) {
271
+ parts := make ([]string , 0 , len (stat ))
272
+ for name , ps := range stat {
273
+ if ps .inCount != 0 {
274
+ parts = append (parts , fmt .Sprintf ("%s: %d/%d" , name , ps .outCount , ps .inCount ))
275
+ }
276
+ }
277
+ r .Log .Infof ("Processors filtering stat (out/in): %s" , strings .Join (parts , ", " ))
278
+ }
279
+
261
280
func collectIssues (resCh <- chan lintRes ) <- chan result.Issue {
262
281
retIssues := make (chan result.Issue , 1024 )
263
282
go func () {
@@ -294,7 +313,7 @@ func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *lint
294
313
return collectIssues (processedLintResultsCh )
295
314
}
296
315
297
- func (r * Runner ) processIssues (issues []result.Issue , sw * timeutils.Stopwatch ) []result.Issue {
316
+ func (r * Runner ) processIssues (issues []result.Issue , sw * timeutils.Stopwatch , statPerProcessor map [ string ] processorStat ) []result.Issue {
298
317
for _ , p := range r .Processors {
299
318
var newIssues []result.Issue
300
319
var err error
@@ -306,6 +325,10 @@ func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch) [
306
325
if err != nil {
307
326
r .Log .Warnf ("Can't process result by %s processor: %s" , p .Name (), err )
308
327
} else {
328
+ stat := statPerProcessor [p .Name ()]
329
+ stat .inCount += len (issues )
330
+ stat .outCount += len (newIssues )
331
+ statPerProcessor [p .Name ()] = stat
309
332
issues = newIssues
310
333
}
311
334
0 commit comments