mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 03:26:30 +00:00
56a854fe14
* 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
45 lines
1.3 KiB
Go
45 lines
1.3 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, ","),
|
|
"ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
|
|
"ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
|
|
"ignoreChanRecvOk": strconv.FormatBool(settings.IgnoreChanRecvOk),
|
|
"ignoreDecls": strings.Join(settings.IgnoreDecls, ","),
|
|
}
|
|
|
|
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.LoadModeTypesInfo)
|
|
}
|