forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnilnil.go
34 lines (29 loc) · 755 Bytes
/
nilnil.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
package nilnil
import (
"github.com/Antonboom/nilnil/pkg/analyzer"
"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.NilNilSettings) *goanalysis.Linter {
a := analyzer.New()
cfg := make(map[string]map[string]any)
if settings != nil {
cfg[a.Name] = map[string]any{
"detect-opposite": settings.DetectOpposite,
}
if b := settings.OnlyTwo; b != nil {
cfg[a.Name]["only-two"] = *b
}
if len(settings.CheckedTypes) != 0 {
cfg[a.Name]["checked-types"] = settings.CheckedTypes
}
}
return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
cfg,
).
WithLoadMode(goanalysis.LoadModeTypesInfo)
}