forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgomnd.go
36 lines (31 loc) · 952 Bytes
/
gomnd.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
package golinters
import (
mnd "github.com/tommy-muehle/go-mnd/v2"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)
func NewGoMND(settings *config.GoMndSettings) *goanalysis.Linter {
var linterCfg map[string]map[string]interface{}
if settings != nil {
// TODO(ldez) For compatibility only, must be drop in v2.
if len(settings.Settings) > 0 {
linterCfg = settings.Settings
} else {
linterCfg = map[string]map[string]interface{}{
"mnd": {
"checks": settings.Checks,
"ignored-numbers": settings.IgnoredNumbers,
"ignored-files": settings.IgnoredFiles,
"ignored-functions": settings.IgnoredFunctions,
},
}
}
}
return goanalysis.NewLinter(
"gomnd",
"An analyzer to detect magic numbers.",
[]*analysis.Analyzer{mnd.Analyzer},
linterCfg,
).WithLoadMode(goanalysis.LoadModeSyntax)
}