Isaev Denis c9a9255238
Speed up packages loading ()
Don't perform extra go env calls in go/packages.
Load only needed go env vars in golangci-lint.
Stay in sync by enabled analyzers in go vet: remove nilness and
atomicalign analyzers, add errorsas analyzer.
Don't build SSA for govet.

Standalone govet runs 25% faster than before. All runs can be 5-10% faster
than before.
Relates: 
2019-09-14 18:48:18 +03:00

93 lines
1.8 KiB
Go

package linter
const (
PresetFormatting = "format"
PresetComplexity = "complexity"
PresetStyle = "style"
PresetBugs = "bugs"
PresetUnused = "unused"
PresetPerformance = "performance"
)
type Config struct {
Linter Linter
EnabledByDefault bool
NeedsTypeInfo bool
NeedsDepsTypeInfo bool
NeedsSSARepr bool
InPresets []string
Speed int // more value means faster execution of linter
AlternativeNames []string
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
ParentLinterName string // used only for megacheck's children now
CanAutoFix bool
}
func (lc *Config) WithTypeInfo() *Config {
lc.NeedsTypeInfo = true
return lc
}
func (lc *Config) WithDepsTypeInfo() *Config {
lc.NeedsTypeInfo = true
lc.NeedsDepsTypeInfo = true
return lc
}
func (lc *Config) WithSSA() *Config {
lc.NeedsTypeInfo = true
lc.NeedsSSARepr = true
return lc
}
func (lc *Config) WithPresets(presets ...string) *Config {
lc.InPresets = presets
return lc
}
func (lc *Config) WithSpeed(speed int) *Config {
lc.Speed = speed
return lc
}
func (lc *Config) WithURL(url string) *Config {
lc.OriginalURL = url
return lc
}
func (lc *Config) WithAlternativeNames(names ...string) *Config {
lc.AlternativeNames = names
return lc
}
func (lc *Config) WithParent(parentLinterName string) *Config {
lc.ParentLinterName = parentLinterName
return lc
}
func (lc *Config) WithAutoFix() *Config {
lc.CanAutoFix = true
return lc
}
func (lc *Config) GetSpeed() int {
return lc.Speed
}
func (lc *Config) AllNames() []string {
return append([]string{lc.Name()}, lc.AlternativeNames...)
}
func (lc *Config) Name() string {
return lc.Linter.Name()
}
func NewConfig(linter Linter) *Config {
return &Config{
Linter: linter,
}
}