depguard: reduce requirements (#2672)
This commit is contained in:
parent
f055441536
commit
8f7f44d175
@ -51,7 +51,7 @@ func NewDepguard() *goanalysis.Linter {
|
|||||||
}
|
}
|
||||||
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
|
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
|
||||||
return resIssues
|
return resIssues
|
||||||
}).WithLoadMode(goanalysis.LoadModeTypesInfo)
|
}).WithLoadMode(goanalysis.LoadModeSyntax)
|
||||||
}
|
}
|
||||||
|
|
||||||
type depGuard struct {
|
type depGuard struct {
|
||||||
|
@ -8,6 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program {
|
func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program {
|
||||||
|
var info types.Info
|
||||||
|
if pass.TypesInfo != nil {
|
||||||
|
info = *pass.TypesInfo
|
||||||
|
}
|
||||||
|
|
||||||
prog := &loader.Program{
|
prog := &loader.Program{
|
||||||
Fset: pass.Fset,
|
Fset: pass.Fset,
|
||||||
Created: []*loader.PackageInfo{
|
Created: []*loader.PackageInfo{
|
||||||
@ -18,7 +23,7 @@ func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program {
|
|||||||
|
|
||||||
Files: pass.Files,
|
Files: pass.Files,
|
||||||
Errors: nil,
|
Errors: nil,
|
||||||
Info: *pass.TypesInfo,
|
Info: info,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AllPackages: map[*types.Package]*loader.PackageInfo{
|
AllPackages: map[*types.Package]*loader.PackageInfo{
|
||||||
@ -28,7 +33,7 @@ func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program {
|
|||||||
TransitivelyErrorFree: true,
|
TransitivelyErrorFree: true,
|
||||||
Files: pass.Files,
|
Files: pass.Files,
|
||||||
Errors: nil,
|
Errors: nil,
|
||||||
Info: *pass.TypesInfo,
|
Info: info,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
|
|
||||||
linter.NewConfig(golinters.NewDepguard()).
|
linter.NewConfig(golinters.NewDepguard()).
|
||||||
WithSince("v1.4.0").
|
WithSince("v1.4.0").
|
||||||
WithLoadForGoAnalysis().
|
|
||||||
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
|
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
|
||||||
WithURL("https://github.com/OpenPeeDeeP/depguard"),
|
WithURL("https://github.com/OpenPeeDeeP/depguard"),
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user