github.com/ldez/golangci-lint@v1.10.1/pkg/result/processors/uniq_by_line.go (about) 1 package processors 2 3 import ( 4 "github.com/golangci/golangci-lint/pkg/result" 5 ) 6 7 type lineToCount map[int]int 8 type fileToLineToCount map[string]lineToCount 9 10 type UniqByLine struct { 11 flc fileToLineToCount 12 } 13 14 func NewUniqByLine() *UniqByLine { 15 return &UniqByLine{ 16 flc: fileToLineToCount{}, 17 } 18 } 19 20 var _ Processor = &UniqByLine{} 21 22 func (p UniqByLine) Name() string { 23 return "uniq_by_line" 24 } 25 26 func (p *UniqByLine) Process(issues []result.Issue) ([]result.Issue, error) { 27 return filterIssues(issues, func(i *result.Issue) bool { 28 lc := p.flc[i.FilePath()] 29 if lc == nil { 30 lc = lineToCount{} 31 p.flc[i.FilePath()] = lc 32 } 33 34 const limit = 1 35 count := lc[i.Line()] 36 if count == limit { 37 return false 38 } 39 40 lc[i.Line()]++ 41 return true 42 }), nil 43 } 44 45 func (p UniqByLine) Finish() {}