
Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimizing - improve handling of unknown linter names in //nolint directives - minimize diff of our megacheck version from the upstream, https://github.com/golang/go/issues/29612 blocks usage of the upstream version - support the new `stylecheck` linter - improve tests coverage for megacheck and nolint related cases - update and use upstream versions of unparam and interfacer instead of forked ones - don't use golangci/tools repo anymore - fix newly found issues after updating linters Also should be noted that megacheck works much faster and consumes less memory in the newest release, therefore golangci-lint works noticeably faster and consumes less memory for large repos. Relates: #314
80 lines
1.5 KiB
Go
80 lines
1.5 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
|
|
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
|
|
}
|
|
|
|
func (lc *Config) WithTypeInfo() *Config {
|
|
lc.NeedsTypeInfo = 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) 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,
|
|
}
|
|
}
|