mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
Update megacheck to the latest version
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
This commit is contained in:
parent
93b2d10537
commit
7705f82591
150 changed files with 17847 additions and 2006 deletions
|
@ -37,6 +37,10 @@ func (m Manager) allPresetsSet() map[string]bool {
|
|||
return ret
|
||||
}
|
||||
|
||||
func (m Manager) GetMetaLinter(name string) linter.MetaLinter {
|
||||
return m.GetMetaLinters()[name]
|
||||
}
|
||||
|
||||
func (m Manager) GetLinterConfig(name string) *linter.Config {
|
||||
lc, ok := m.nameToLC[name]
|
||||
if !ok {
|
||||
|
@ -57,12 +61,26 @@ func enableLinterConfigs(lcs []*linter.Config, isEnabled func(lc *linter.Config)
|
|||
return ret
|
||||
}
|
||||
|
||||
func (Manager) GetMetaLinters() map[string]linter.MetaLinter {
|
||||
metaLinters := []linter.MetaLinter{
|
||||
golinters.MegacheckMetalinter{},
|
||||
}
|
||||
|
||||
ret := map[string]linter.MetaLinter{}
|
||||
for _, metaLinter := range metaLinters {
|
||||
ret[metaLinter.Name()] = metaLinter
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
||||
lcs := []*linter.Config{
|
||||
linter.NewConfig(golinters.Govet{}).
|
||||
WithTypeInfo().
|
||||
WithPresets(linter.PresetBugs).
|
||||
WithSpeed(4).
|
||||
WithAlternativeNames("vet", "vetshadow").
|
||||
WithURL("https://golang.org/cmd/vet/"),
|
||||
linter.NewConfig(golinters.Errcheck{}).
|
||||
WithTypeInfo().
|
||||
|
@ -74,21 +92,26 @@ func (Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||
WithSpeed(3).
|
||||
WithURL("https://github.com/golang/lint"),
|
||||
|
||||
linter.NewConfig(golinters.Megacheck{StaticcheckEnabled: true}).
|
||||
linter.NewConfig(golinters.NewStaticcheck()).
|
||||
WithSSA().
|
||||
WithPresets(linter.PresetBugs).
|
||||
WithSpeed(2).
|
||||
WithURL("https://staticcheck.io/"),
|
||||
linter.NewConfig(golinters.Megacheck{UnusedEnabled: true}).
|
||||
linter.NewConfig(golinters.NewUnused()).
|
||||
WithSSA().
|
||||
WithPresets(linter.PresetUnused).
|
||||
WithSpeed(5).
|
||||
WithURL("https://github.com/dominikh/go-tools/tree/master/cmd/unused"),
|
||||
linter.NewConfig(golinters.Megacheck{GosimpleEnabled: true}).
|
||||
linter.NewConfig(golinters.NewGosimple()).
|
||||
WithSSA().
|
||||
WithPresets(linter.PresetStyle).
|
||||
WithSpeed(5).
|
||||
WithURL("https://github.com/dominikh/go-tools/tree/master/cmd/gosimple"),
|
||||
linter.NewConfig(golinters.NewStylecheck()).
|
||||
WithSSA().
|
||||
WithPresets(linter.PresetStyle).
|
||||
WithSpeed(5).
|
||||
WithURL("https://github.com/dominikh/go-tools/tree/master/stylecheck"),
|
||||
|
||||
linter.NewConfig(golinters.Gosec{}).
|
||||
WithTypeInfo().
|
||||
|
@ -156,11 +179,6 @@ func (Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||
WithPresets(linter.PresetPerformance).
|
||||
WithSpeed(10).
|
||||
WithURL("https://github.com/mdempsky/maligned"),
|
||||
linter.NewConfig(golinters.Megacheck{GosimpleEnabled: true, UnusedEnabled: true, StaticcheckEnabled: true}).
|
||||
WithSSA().
|
||||
WithPresets(linter.PresetStyle, linter.PresetBugs, linter.PresetUnused).
|
||||
WithSpeed(1).
|
||||
WithURL("https://github.com/dominikh/go-tools/tree/master/cmd/megacheck"),
|
||||
linter.NewConfig(golinters.Depguard{}).
|
||||
WithTypeInfo().
|
||||
WithPresets(linter.PresetStyle).
|
||||
|
@ -207,22 +225,22 @@ func (Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||
}
|
||||
|
||||
isLocalRun := os.Getenv("GOLANGCI_COM_RUN") == ""
|
||||
enabled := map[string]bool{
|
||||
golinters.Govet{}.Name(): true,
|
||||
golinters.Errcheck{}.Name(): true,
|
||||
golinters.Megacheck{StaticcheckEnabled: true}.Name(): true,
|
||||
golinters.Megacheck{UnusedEnabled: true}.Name(): true,
|
||||
golinters.Megacheck{GosimpleEnabled: true}.Name(): true,
|
||||
golinters.Structcheck{}.Name(): true,
|
||||
golinters.Varcheck{}.Name(): true,
|
||||
golinters.Ineffassign{}.Name(): true,
|
||||
golinters.Deadcode{}.Name(): true,
|
||||
enabledByDefault := map[string]bool{
|
||||
golinters.Govet{}.Name(): true,
|
||||
golinters.Errcheck{}.Name(): true,
|
||||
golinters.Staticcheck{}.Name(): true,
|
||||
golinters.Unused{}.Name(): true,
|
||||
golinters.Gosimple{}.Name(): true,
|
||||
golinters.Structcheck{}.Name(): true,
|
||||
golinters.Varcheck{}.Name(): true,
|
||||
golinters.Ineffassign{}.Name(): true,
|
||||
golinters.Deadcode{}.Name(): true,
|
||||
|
||||
// don't typecheck for golangci.com: too many troubles
|
||||
golinters.TypeCheck{}.Name(): isLocalRun,
|
||||
}
|
||||
return enableLinterConfigs(lcs, func(lc *linter.Config) bool {
|
||||
return enabled[lc.Name()]
|
||||
return enabledByDefault[lc.Name()]
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue