github.com/ldez/golangci-lint@v1.10.1/pkg/result/processors/skip_files.go (about) 1 package processors 2 3 import ( 4 "fmt" 5 "regexp" 6 7 "github.com/golangci/golangci-lint/pkg/result" 8 ) 9 10 type SkipFiles struct { 11 patterns []*regexp.Regexp 12 } 13 14 var _ Processor = SkipFiles{} 15 16 func NewSkipFiles(patterns []string) (*SkipFiles, error) { 17 var patternsRe []*regexp.Regexp 18 for _, p := range patterns { 19 patternRe, err := regexp.Compile(p) 20 if err != nil { 21 return nil, fmt.Errorf("can't compile regexp %q: %s", p, err) 22 } 23 patternsRe = append(patternsRe, patternRe) 24 } 25 26 return &SkipFiles{ 27 patterns: patternsRe, 28 }, nil 29 } 30 31 func (p SkipFiles) Name() string { 32 return "skip_files" 33 } 34 35 func (p SkipFiles) Process(issues []result.Issue) ([]result.Issue, error) { 36 if len(p.patterns) == 0 { 37 return issues, nil 38 } 39 40 return filterIssues(issues, func(i *result.Issue) bool { 41 for _, p := range p.patterns { 42 if p.MatchString(i.FilePath()) { 43 return false 44 } 45 } 46 47 return true 48 }), nil 49 } 50 51 func (p SkipFiles) Finish() {}