woodpecker/vendor/github.com/golangci/golangci-lint/pkg/golinters/gomnd.go
6543 56a854fe14
Update deps (#789)
* update github.com/docker/cli

* update github.com/docker/distribution

* update github.com/docker/docker

* update github.com/gin-gonic/gin

* update github.com/golang-jwt/jwt/v4

* update github.com/golangci/golangci-lint

* update github.com/gorilla/securecookie

* update github.com/mattn/go-sqlite3

* update github.com/moby/moby

* update github.com/prometheus/client_golang

* update github.com/xanzy/go-gitlab
2022-02-24 17:33:24 +01:00

45 lines
1.1 KiB
Go

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 {
cfg := make(map[string]interface{})
if len(settings.Checks) > 0 {
cfg["checks"] = settings.Checks
}
if len(settings.IgnoredNumbers) > 0 {
cfg["ignored-numbers"] = settings.IgnoredNumbers
}
if len(settings.IgnoredFiles) > 0 {
cfg["ignored-files"] = settings.IgnoredFiles
}
if len(settings.IgnoredFunctions) > 0 {
cfg["ignored-functions"] = settings.IgnoredFunctions
}
linterCfg = map[string]map[string]interface{}{
"mnd": cfg,
}
}
}
return goanalysis.NewLinter(
"gomnd",
"An analyzer to detect magic numbers.",
[]*analysis.Analyzer{mnd.Analyzer},
linterCfg,
).WithLoadMode(goanalysis.LoadModeSyntax)
}