feat: remove some go1.18 limitations (#3001)

* fix: restore some linters

- govet(nilness,unusedwrite)
- bodyclose
- contextcheck
- nilerr
- noctx
- tparallel

* fix: remove structcheck from the default linters.
This commit is contained in:
Ludovic Fernandez 2022-07-21 16:52:06 +02:00 committed by GitHub
parent eddfdbba7c
commit d44cd49a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 18 deletions

View File

@ -155,11 +155,6 @@ func analyzersFromConfig(settings *config.GovetSettings) []*analysis.Analyzer {
} }
func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool { func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers []*analysis.Analyzer) bool {
if (name == nilness.Analyzer.Name || name == unusedwrite.Analyzer.Name) &&
config.IsGreaterThanOrEqualGo118(cfg.Go) {
return false
}
if cfg.EnableAll { if cfg.EnableAll {
for _, n := range cfg.Disable { for _, n := range cfg.Disable {
if n == name { if n == name {

View File

@ -288,8 +288,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithSince("v1.18.0"). WithSince("v1.18.0").
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs). WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/timakin/bodyclose"). WithURL("https://github.com/timakin/bodyclose"),
WithNoopFallback(m.cfg),
linter.NewConfig(golinters.NewContainedCtx()). linter.NewConfig(golinters.NewContainedCtx()).
WithSince("1.44.0"). WithSince("1.44.0").
@ -300,8 +299,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithSince("v1.43.0"). WithSince("v1.43.0").
WithPresets(linter.PresetBugs). WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithURL("https://github.com/sylvia7788/contextcheck"). WithURL("https://github.com/sylvia7788/contextcheck"),
WithNoopFallback(m.cfg),
linter.NewConfig(golinters.NewCyclop(cyclopCfg)). linter.NewConfig(golinters.NewCyclop(cyclopCfg)).
WithSince("v1.37.0"). WithSince("v1.37.0").
@ -561,8 +559,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithURL("https://github.com/mvdan/interfacer"). WithURL("https://github.com/mvdan/interfacer").
Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", ""). Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", ""),
WithNoopFallback(m.cfg),
linter.NewConfig(golinters.NewIreturn(ireturnCfg)). linter.NewConfig(golinters.NewIreturn(ireturnCfg)).
WithSince("v1.43.0"). WithSince("v1.43.0").
@ -612,8 +609,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithSince("v1.38.0"). WithSince("v1.38.0").
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs). WithPresets(linter.PresetBugs).
WithURL("https://github.com/gostaticanalysis/nilerr"). WithURL("https://github.com/gostaticanalysis/nilerr"),
WithNoopFallback(m.cfg),
linter.NewConfig(golinters.NewNilNil(nilNilCfg)). linter.NewConfig(golinters.NewNilNil(nilNilCfg)).
WithSince("v1.43.0"). WithSince("v1.43.0").
@ -630,8 +626,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithSince("v1.28.0"). WithSince("v1.28.0").
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs). WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/sonatard/noctx"). WithURL("https://github.com/sonatard/noctx"),
WithNoopFallback(m.cfg),
linter.NewConfig(golinters.NewNoNamedReturns(noNamedReturnsCfg)). linter.NewConfig(golinters.NewNoNamedReturns(noNamedReturnsCfg)).
WithSince("v1.46.0"). WithSince("v1.46.0").
@ -742,8 +737,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithSince("v1.32.0"). WithSince("v1.32.0").
WithPresets(linter.PresetStyle, linter.PresetTest). WithPresets(linter.PresetStyle, linter.PresetTest).
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().
WithURL("https://github.com/moricho/tparallel"). WithURL("https://github.com/moricho/tparallel"),
WithNoopFallback(m.cfg),
linter.NewConfig(golinters.NewTypecheck()). linter.NewConfig(golinters.NewTypecheck()).
WithSince("v1.3.0"). WithSince("v1.3.0").
@ -821,7 +815,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
golinters.NewStaticcheck(staticcheckCfg).Name(): true, golinters.NewStaticcheck(staticcheckCfg).Name(): true,
golinters.NewUnused(unusedCfg).Name(): true, golinters.NewUnused(unusedCfg).Name(): true,
golinters.NewGosimple(gosimpleCfg).Name(): true, golinters.NewGosimple(gosimpleCfg).Name(): true,
golinters.NewStructcheck(structcheckCfg).Name(): true,
golinters.NewVarcheck(varcheckCfg).Name(): true, golinters.NewVarcheck(varcheckCfg).Name(): true,
golinters.NewIneffassign().Name(): true, golinters.NewIneffassign().Name(): true,
golinters.NewDeadcode().Name(): true, golinters.NewDeadcode().Name(): true,