golangci-lint/pkg/golinters/wrapcheck.go
Oleksandr Redko ce020c6be1
dev: use analyzer fields for name, doc instead of hardcoded strings (#4214)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-11-20 20:53:18 +01:00

37 lines
928 B
Go

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"
)
func NewWrapcheck(settings *config.WrapcheckSettings) *goanalysis.Linter {
cfg := wrapcheck.NewDefaultConfig()
if settings != nil {
if len(settings.IgnoreSigs) != 0 {
cfg.IgnoreSigs = settings.IgnoreSigs
}
if len(settings.IgnoreSigRegexps) != 0 {
cfg.IgnoreSigRegexps = settings.IgnoreSigRegexps
}
if len(settings.IgnorePackageGlobs) != 0 {
cfg.IgnorePackageGlobs = settings.IgnorePackageGlobs
}
if len(settings.IgnoreInterfaceRegexps) != 0 {
cfg.IgnoreInterfaceRegexps = settings.IgnoreInterfaceRegexps
}
}
a := wrapcheck.NewAnalyzer(cfg)
return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}