github.com/ldez/golangci-lint@v1.10.1/pkg/result/processors/max_from_linter.go (about) 1 package processors 2 3 import ( 4 "github.com/golangci/golangci-lint/pkg/logutils" 5 "github.com/golangci/golangci-lint/pkg/result" 6 ) 7 8 type MaxFromLinter struct { 9 lc linterToCountMap 10 limit int 11 log logutils.Log 12 } 13 14 var _ Processor = &MaxFromLinter{} 15 16 func NewMaxFromLinter(limit int, log logutils.Log) *MaxFromLinter { 17 return &MaxFromLinter{ 18 lc: linterToCountMap{}, 19 limit: limit, 20 log: log, 21 } 22 } 23 24 func (p MaxFromLinter) Name() string { 25 return "max_from_linter" 26 } 27 28 func (p *MaxFromLinter) Process(issues []result.Issue) ([]result.Issue, error) { 29 if p.limit <= 0 { // no limit 30 return issues, nil 31 } 32 33 return filterIssues(issues, func(i *result.Issue) bool { 34 p.lc[i.FromLinter]++ // always inc for stat 35 return p.lc[i.FromLinter] <= p.limit 36 }), nil 37 } 38 39 func (p MaxFromLinter) Finish() { 40 walkStringToIntMapSortedByValue(p.lc, func(linter string, count int) { 41 if count > p.limit { 42 p.log.Infof("%d/%d issues from linter %s were hidden, use --max-issues-per-linter", 43 count-p.limit, count, linter) 44 } 45 }) 46 }