github.com/thrasher-corp/golangci-lint@v1.17.3/pkg/lint/linter/config.go (about) 1 package linter 2 3 const ( 4 PresetFormatting = "format" 5 PresetComplexity = "complexity" 6 PresetStyle = "style" 7 PresetBugs = "bugs" 8 PresetUnused = "unused" 9 PresetPerformance = "performance" 10 ) 11 12 type Config struct { 13 Linter Linter 14 EnabledByDefault bool 15 16 NeedsTypeInfo bool 17 NeedsSSARepr bool 18 19 InPresets []string 20 Speed int // more value means faster execution of linter 21 AlternativeNames []string 22 23 OriginalURL string // URL of original (not forked) repo, needed for autogenerated README 24 ParentLinterName string // used only for megacheck's children now 25 CanAutoFix bool 26 } 27 28 func (lc *Config) WithTypeInfo() *Config { 29 lc.NeedsTypeInfo = true 30 return lc 31 } 32 33 func (lc *Config) WithSSA() *Config { 34 lc.NeedsTypeInfo = true 35 lc.NeedsSSARepr = true 36 return lc 37 } 38 39 func (lc *Config) WithPresets(presets ...string) *Config { 40 lc.InPresets = presets 41 return lc 42 } 43 44 func (lc *Config) WithSpeed(speed int) *Config { 45 lc.Speed = speed 46 return lc 47 } 48 49 func (lc *Config) WithURL(url string) *Config { 50 lc.OriginalURL = url 51 return lc 52 } 53 54 func (lc *Config) WithAlternativeNames(names ...string) *Config { 55 lc.AlternativeNames = names 56 return lc 57 } 58 59 func (lc *Config) WithParent(parentLinterName string) *Config { 60 lc.ParentLinterName = parentLinterName 61 return lc 62 } 63 64 func (lc *Config) WithAutoFix() *Config { 65 lc.CanAutoFix = true 66 return lc 67 } 68 69 func (lc *Config) GetSpeed() int { 70 return lc.Speed 71 } 72 73 func (lc *Config) AllNames() []string { 74 return append([]string{lc.Name()}, lc.AlternativeNames...) 75 } 76 77 func (lc *Config) Name() string { 78 return lc.Linter.Name() 79 } 80 81 func NewConfig(linter Linter) *Config { 82 return &Config{ 83 Linter: linter, 84 } 85 }