-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathwrapcheck.go
40 lines (33 loc) · 1 KB
/
wrapcheck.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package wrapcheck
import (
"github.com/tomarrell/wrapcheck/v2/wrapcheck"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/v2/pkg/config"
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
)
func New(settings *config.WrapcheckSettings) *goanalysis.Linter {
cfg := wrapcheck.NewDefaultConfig()
if settings != nil {
cfg.ExtraIgnoreSigs = settings.ExtraIgnoreSigs
cfg.ReportInternalErrors = settings.ReportInternalErrors
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)
}