2021-11-14 20:01:54 +00:00
|
|
|
package golinters
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/tomarrell/wrapcheck/v2/wrapcheck"
|
|
|
|
"golang.org/x/tools/go/analysis"
|
|
|
|
|
|
|
|
"github.com/golangci/golangci-lint/pkg/config"
|
|
|
|
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
|
|
|
)
|
|
|
|
|
|
|
|
const wrapcheckName = "wrapcheck"
|
|
|
|
|
|
|
|
func NewWrapcheck(settings *config.WrapcheckSettings) *goanalysis.Linter {
|
|
|
|
cfg := wrapcheck.NewDefaultConfig()
|
|
|
|
if settings != nil {
|
|
|
|
if len(settings.IgnoreSigs) != 0 {
|
|
|
|
cfg.IgnoreSigs = settings.IgnoreSigs
|
|
|
|
}
|
2022-02-24 16:33:24 +00:00
|
|
|
if len(settings.IgnoreSigRegexps) != 0 {
|
|
|
|
cfg.IgnoreSigRegexps = settings.IgnoreSigRegexps
|
|
|
|
}
|
2021-11-14 20:01:54 +00:00
|
|
|
if len(settings.IgnorePackageGlobs) != 0 {
|
|
|
|
cfg.IgnorePackageGlobs = settings.IgnorePackageGlobs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a := wrapcheck.NewAnalyzer(cfg)
|
|
|
|
|
|
|
|
return goanalysis.NewLinter(
|
|
|
|
wrapcheckName,
|
|
|
|
a.Doc,
|
|
|
|
[]*analysis.Analyzer{a},
|
|
|
|
nil,
|
|
|
|
).WithLoadMode(goanalysis.LoadModeTypesInfo)
|
|
|
|
}
|