bump varnamelen to v0.8.0 (#2703)
This commit is contained in:
parent
b8c061e5f3
commit
d2ccc6d2bb
@ -1473,12 +1473,15 @@ linters-settings:
|
||||
# Variable names that are at least this long will be ignored.
|
||||
# Default: 3
|
||||
min-name-length: 2
|
||||
# Check method receiver names.
|
||||
# Check method receivers.
|
||||
# Default: false
|
||||
check-receiver: true
|
||||
# Check named return values.
|
||||
# Default: false
|
||||
check-return: true
|
||||
# Check type parameters.
|
||||
# Default: false
|
||||
check-type-param: true
|
||||
# Ignore "ok" variables that hold the bool return value of a type assertion.
|
||||
# Default: false
|
||||
ignore-type-assert-ok: true
|
||||
@ -1493,8 +1496,11 @@ linters-settings:
|
||||
ignore-names:
|
||||
- err
|
||||
# Optional list of variable declarations that should be ignored completely.
|
||||
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>"
|
||||
# for variables, or "const <name>" for constants.
|
||||
# Entries must be in one of the following forms (see below for examples):
|
||||
# - for variables, parameters, named return values, method receivers, or type parameters:
|
||||
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
|
||||
# - for constants: const <name>
|
||||
#
|
||||
# Default: []
|
||||
ignore-decls:
|
||||
- c echo.Context
|
||||
@ -1503,6 +1509,8 @@ linters-settings:
|
||||
- e error
|
||||
- i int
|
||||
- const C
|
||||
- T any
|
||||
- m map[string]int
|
||||
|
||||
whitespace:
|
||||
# Enforces newlines (or comments) after every multi-line if statement.
|
||||
|
2
go.mod
2
go.mod
@ -13,7 +13,7 @@ require (
|
||||
github.com/ashanbrown/forbidigo v1.3.0
|
||||
github.com/ashanbrown/makezero v1.1.1
|
||||
github.com/bkielbasa/cyclop v1.2.0
|
||||
github.com/blizzy78/varnamelen v0.6.2
|
||||
github.com/blizzy78/varnamelen v0.8.0
|
||||
github.com/bombsimon/wsl/v3 v3.3.0
|
||||
github.com/breml/bidichk v0.2.3
|
||||
github.com/breml/errchkjson v0.3.0
|
||||
|
4
go.sum
generated
4
go.sum
generated
@ -98,8 +98,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bkielbasa/cyclop v1.2.0 h1:7Jmnh0yL2DjKfw28p86YTd/B4lRGcNuu12sKE35sM7A=
|
||||
github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI=
|
||||
github.com/blizzy78/varnamelen v0.6.2 h1:Z857yhnsqKadJo+ALsdpRpN5SCyTTR5rEX+hwVGY4Vk=
|
||||
github.com/blizzy78/varnamelen v0.6.2/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k=
|
||||
github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M=
|
||||
github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k=
|
||||
github.com/bombsimon/wsl/v3 v3.3.0 h1:Mka/+kRLoQJq7g2rggtgQsjuI/K5Efd87WX96EWFxjM=
|
||||
github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc=
|
||||
github.com/breml/bidichk v0.2.3 h1:qe6ggxpTfA8E75hdjWPZ581sY3a2lnl0IRxLQFelECI=
|
||||
|
@ -579,6 +579,7 @@ type VarnamelenSettings struct {
|
||||
MinNameLength int `mapstructure:"min-name-length"`
|
||||
CheckReceiver bool `mapstructure:"check-receiver"`
|
||||
CheckReturn bool `mapstructure:"check-return"`
|
||||
CheckTypeParam bool `mapstructure:"check-type-param"`
|
||||
IgnoreNames []string `mapstructure:"ignore-names"`
|
||||
IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
|
||||
IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`
|
||||
|
@ -12,13 +12,14 @@ import (
|
||||
)
|
||||
|
||||
func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
|
||||
a := varnamelen.NewAnalyzer()
|
||||
|
||||
analyzer := 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),
|
||||
"checkTypeParam": strconv.FormatBool(settings.CheckTypeParam),
|
||||
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
|
||||
"ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
|
||||
"ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
|
||||
@ -33,13 +34,13 @@ func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
|
||||
vnlCfg["minNameLength"] = strconv.Itoa(settings.MinNameLength)
|
||||
}
|
||||
|
||||
cfg[a.Name] = vnlCfg
|
||||
cfg[analyzer.Name] = vnlCfg
|
||||
}
|
||||
|
||||
return goanalysis.NewLinter(
|
||||
a.Name,
|
||||
analyzer.Name,
|
||||
"checks that the length of a variable's name matches its scope",
|
||||
[]*analysis.Analyzer{a},
|
||||
[]*analysis.Analyzer{analyzer},
|
||||
cfg,
|
||||
).WithLoadMode(goanalysis.LoadModeTypesInfo)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user