mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-13 12:06:29 +00:00
82fd65665f
bidichk checks for dangerous unicode character sequences (https://github.com/golangci/golangci-lint/pull/2330)
41 lines
1 KiB
Go
41 lines
1 KiB
Go
package golinters
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/blizzy78/varnamelen"
|
|
"golang.org/x/tools/go/analysis"
|
|
|
|
"github.com/golangci/golangci-lint/pkg/config"
|
|
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
|
)
|
|
|
|
func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
|
|
a := varnamelen.NewAnalyzer()
|
|
|
|
cfg := map[string]map[string]interface{}{}
|
|
if settings != nil {
|
|
vnlCfg := map[string]interface{}{
|
|
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
|
|
"checkReturn": strconv.FormatBool(settings.CheckReturn),
|
|
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
|
|
}
|
|
|
|
if settings.MaxDistance > 0 {
|
|
vnlCfg["maxDistance"] = strconv.Itoa(settings.MaxDistance)
|
|
}
|
|
if settings.MinNameLength > 0 {
|
|
vnlCfg["minNameLength"] = strconv.Itoa(settings.MinNameLength)
|
|
}
|
|
|
|
cfg[a.Name] = vnlCfg
|
|
}
|
|
|
|
return goanalysis.NewLinter(
|
|
a.Name,
|
|
"checks that the length of a variable's name matches its scope",
|
|
[]*analysis.Analyzer{a},
|
|
cfg,
|
|
).WithLoadMode(goanalysis.LoadModeSyntax)
|
|
}
|