fix: linters load mode (#1862)

This commit is contained in:
Ludovic Fernandez 2021-03-21 23:06:40 +01:00 committed by GitHub
parent 8db518cee0
commit 809be02635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 18 deletions

View File

@ -15,5 +15,5 @@ func NewForceTypeAssert() *goanalysis.Linter {
"finds forced type assertions", "finds forced type assertions",
[]*analysis.Analyzer{a}, []*analysis.Analyzer{a},
nil, nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo) ).WithLoadMode(goanalysis.LoadModeSyntax)
} }

View File

@ -13,5 +13,5 @@ func NewIneffassign() *goanalysis.Linter {
"Detects when assignments to existing variables are not used", "Detects when assignments to existing variables are not used",
[]*analysis.Analyzer{ineffassign.Analyzer}, []*analysis.Analyzer{ineffassign.Analyzer},
nil, nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo) ).WithLoadMode(goanalysis.LoadModeSyntax)
} }

View File

@ -56,5 +56,5 @@ func NewMakezero() *goanalysis.Linter {
} }
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { }).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
return resIssues return resIssues
}).WithLoadMode(goanalysis.LoadModeSyntax | goanalysis.LoadModeTypesInfo) }).WithLoadMode(goanalysis.LoadModeTypesInfo)
} }

View File

@ -17,5 +17,5 @@ func NewParallelTest() *goanalysis.Linter {
"paralleltest detects missing usage of t.Parallel() method in your Go test", "paralleltest detects missing usage of t.Parallel() method in your Go test",
analyzers, analyzers,
nil, nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo) ).WithLoadMode(goanalysis.LoadModeSyntax)
} }

View File

@ -59,7 +59,7 @@ func NewUnused() *goanalysis.Linter {
nil, nil,
).WithIssuesReporter(func(lintCtx *linter.Context) []goanalysis.Issue { ).WithIssuesReporter(func(lintCtx *linter.Context) []goanalysis.Issue {
return resIssues return resIssues
}).WithLoadMode(goanalysis.LoadModeSyntax | goanalysis.LoadModeTypesInfo) }).WithLoadMode(goanalysis.LoadModeTypesInfo)
return lnt return lnt
} }

View File

@ -218,7 +218,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithURL("https://github.com/mdempsky/unconvert"), WithURL("https://github.com/mdempsky/unconvert"),
linter.NewConfig(golinters.NewIneffassign()). linter.NewConfig(golinters.NewIneffassign()).
WithSince("v1.0.0"). WithSince("v1.0.0").
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused). WithPresets(linter.PresetUnused).
WithURL("https://github.com/gordonklaus/ineffassign"), WithURL("https://github.com/gordonklaus/ineffassign"),
linter.NewConfig(golinters.NewDupl()). linter.NewConfig(golinters.NewDupl()).
@ -226,7 +225,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithURL("https://github.com/mibk/dupl"), WithURL("https://github.com/mibk/dupl"),
linter.NewConfig(golinters.NewGoconst()). linter.NewConfig(golinters.NewGoconst()).
WithSince(""). WithSince("v1.0.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithURL("https://github.com/jgautheron/goconst"), WithURL("https://github.com/jgautheron/goconst"),
linter.NewConfig(golinters.NewDeadcode()). linter.NewConfig(golinters.NewDeadcode()).
@ -255,7 +254,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewAsciicheck()). linter.NewConfig(golinters.NewAsciicheck()).
WithSince("v1.26.0"). WithSince("v1.26.0").
WithPresets(linter.PresetBugs, linter.PresetStyle). WithPresets(linter.PresetBugs, linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/tdakkota/asciicheck"), WithURL("https://github.com/tdakkota/asciicheck"),
linter.NewConfig(golinters.NewGofmt()). linter.NewConfig(golinters.NewGofmt()).
@ -276,12 +274,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewGoHeader()). linter.NewConfig(golinters.NewGoHeader()).
WithSince("v1.28.0"). WithSince("v1.28.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/denis-tingajkin/go-header"), WithURL("https://github.com/denis-tingajkin/go-header"),
linter.NewConfig(golinters.NewGci()). linter.NewConfig(golinters.NewGci()).
WithSince("v1.30.0"). WithSince("v1.30.0").
WithPresets(linter.PresetFormatting, linter.PresetImport). WithPresets(linter.PresetFormatting, linter.PresetImport).
WithLoadForGoAnalysis().
WithAutoFix(). WithAutoFix().
WithURL("https://github.com/daixiang0/gci"), WithURL("https://github.com/daixiang0/gci"),
linter.NewConfig(golinters.NewMaligned()). linter.NewConfig(golinters.NewMaligned()).
@ -371,7 +367,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewGomodguard()). linter.NewConfig(golinters.NewGomodguard()).
WithSince("v1.25.0"). WithSince("v1.25.0").
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule). WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
WithLoadForGoAnalysis().
WithURL("https://github.com/ryancurrah/gomodguard"), WithURL("https://github.com/ryancurrah/gomodguard"),
linter.NewConfig(golinters.NewGodot()). linter.NewConfig(golinters.NewGodot()).
WithSince("v1.25.0"). WithSince("v1.25.0").
@ -381,7 +376,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewTestpackage(testpackageCfg)). linter.NewConfig(golinters.NewTestpackage(testpackageCfg)).
WithSince("v1.25.0"). WithSince("v1.25.0").
WithPresets(linter.PresetStyle, linter.PresetTest). WithPresets(linter.PresetStyle, linter.PresetTest).
WithLoadForGoAnalysis().
WithURL("https://github.com/maratori/testpackage"), WithURL("https://github.com/maratori/testpackage"),
linter.NewConfig(golinters.NewNestif()). linter.NewConfig(golinters.NewNestif()).
WithSince("v1.25.0"). WithSince("v1.25.0").
@ -405,7 +399,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewNLReturn()). linter.NewConfig(golinters.NewNLReturn()).
WithSince("v1.30.0"). WithSince("v1.30.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/ssgreg/nlreturn"), WithURL("https://github.com/ssgreg/nlreturn"),
linter.NewConfig(golinters.NewWrapcheck()). linter.NewConfig(golinters.NewWrapcheck()).
WithSince("v1.32.0"). WithSince("v1.32.0").
@ -435,7 +428,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewParallelTest()). linter.NewConfig(golinters.NewParallelTest()).
WithSince("v1.33.0"). WithSince("v1.33.0").
WithPresets(linter.PresetStyle, linter.PresetTest). WithPresets(linter.PresetStyle, linter.PresetTest).
WithLoadForGoAnalysis().
WithURL("https://github.com/kunwardeep/paralleltest"), WithURL("https://github.com/kunwardeep/paralleltest"),
linter.NewConfig(golinters.NewMakezero()). linter.NewConfig(golinters.NewMakezero()).
WithSince("v1.34.0"). WithSince("v1.34.0").
@ -482,12 +474,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
linter.NewConfig(golinters.NewForceTypeAssert()). linter.NewConfig(golinters.NewForceTypeAssert()).
WithSince("v1.38.0"). WithSince("v1.38.0").
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/gostaticanalysis/forcetypeassert"), WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)). linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)).
WithSince("v1.39.0"). WithSince("v1.39.0").
WithPresets(linter.PresetStyle, linter.PresetModule). WithPresets(linter.PresetStyle, linter.PresetModule).
WithLoadForGoAnalysis().
WithURL("https://github.com/ldez/gomoddirectives"), WithURL("https://github.com/ldez/gomoddirectives"),
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives

View File

@ -1,8 +1,23 @@
//args: -Easciicheck //args: -Easciicheck
package testdata package testdata
import "time" import (
"fmt"
"time"
)
type TеstStruct struct { // ERROR `identifier "TеstStruct" contain non-ASCII character: U\+0435 'е'` type AsciicheckTеstStruct struct { // ERROR `identifier "AsciicheckTеstStruct" contain non-ASCII character: U\+0435 'е'`
Date time.Time Date time.Time
} }
type AsciicheckField struct{}
type AsciicheckJustStruct struct {
Tеst AsciicheckField // ERROR `identifier "Tеst" contain non-ASCII character: U\+0435 'е'`
}
func AsciicheckTеstFunc() { // ERROR `identifier "AsciicheckTеstFunc" contain non-ASCII character: U\+0435 'е'`
var tеstVar int // ERROR `identifier "tеstVar" contain non-ASCII character: U\+0435 'е'`
tеstVar = 0
fmt.Println(tеstVar)
}