2021-11-14 20:01:54 +00:00
|
|
|
package golinters
|
|
|
|
|
|
|
|
import (
|
|
|
|
"4d63.com/gochecknoglobals/checknoglobals"
|
|
|
|
"golang.org/x/tools/go/analysis"
|
|
|
|
|
|
|
|
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewGochecknoglobals() *goanalysis.Linter {
|
|
|
|
gochecknoglobals := checknoglobals.Analyzer()
|
|
|
|
|
2022-02-24 16:33:24 +00:00
|
|
|
// gochecknoglobals only lints test files if the `-t` flag is passed, so we
|
2021-11-14 20:01:54 +00:00
|
|
|
// pass the `t` flag as true to the analyzer before running it. This can be
|
2022-02-24 16:33:24 +00:00
|
|
|
// turned off by using the regular golangci-lint flags such as `--tests` or
|
2021-11-14 20:01:54 +00:00
|
|
|
// `--skip-files`.
|
|
|
|
linterConfig := map[string]map[string]interface{}{
|
|
|
|
gochecknoglobals.Name: {
|
|
|
|
"t": true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return goanalysis.NewLinter(
|
|
|
|
gochecknoglobals.Name,
|
|
|
|
gochecknoglobals.Doc,
|
|
|
|
[]*analysis.Analyzer{gochecknoglobals},
|
|
|
|
linterConfig,
|
|
|
|
).WithLoadMode(goanalysis.LoadModeSyntax)
|
|
|
|
}
|