Skip to content

Commit d2ccc6d

Browse files
authored
bump varnamelen to v0.8.0 (#2703)
1 parent b8c061e commit d2ccc6d

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

.golangci.example.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -1473,12 +1473,15 @@ linters-settings:
14731473
# Variable names that are at least this long will be ignored.
14741474
# Default: 3
14751475
min-name-length: 2
1476-
# Check method receiver names.
1476+
# Check method receivers.
14771477
# Default: false
14781478
check-receiver: true
14791479
# Check named return values.
14801480
# Default: false
14811481
check-return: true
1482+
# Check type parameters.
1483+
# Default: false
1484+
check-type-param: true
14821485
# Ignore "ok" variables that hold the bool return value of a type assertion.
14831486
# Default: false
14841487
ignore-type-assert-ok: true
@@ -1493,8 +1496,11 @@ linters-settings:
14931496
ignore-names:
14941497
- err
14951498
# Optional list of variable declarations that should be ignored completely.
1496-
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>"
1497-
# for variables, or "const <name>" for constants.
1499+
# Entries must be in one of the following forms (see below for examples):
1500+
# - for variables, parameters, named return values, method receivers, or type parameters:
1501+
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
1502+
# - for constants: const <name>
1503+
#
14981504
# Default: []
14991505
ignore-decls:
15001506
- c echo.Context
@@ -1503,6 +1509,8 @@ linters-settings:
15031509
- e error
15041510
- i int
15051511
- const C
1512+
- T any
1513+
- m map[string]int
15061514

15071515
whitespace:
15081516
# Enforces newlines (or comments) after every multi-line if statement.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/ashanbrown/forbidigo v1.3.0
1414
github.com/ashanbrown/makezero v1.1.1
1515
github.com/bkielbasa/cyclop v1.2.0
16-
github.com/blizzy78/varnamelen v0.6.2
16+
github.com/blizzy78/varnamelen v0.8.0
1717
github.com/bombsimon/wsl/v3 v3.3.0
1818
github.com/breml/bidichk v0.2.3
1919
github.com/breml/errchkjson v0.3.0

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/linters_settings.go

+1
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ type VarnamelenSettings struct {
579579
MinNameLength int `mapstructure:"min-name-length"`
580580
CheckReceiver bool `mapstructure:"check-receiver"`
581581
CheckReturn bool `mapstructure:"check-return"`
582+
CheckTypeParam bool `mapstructure:"check-type-param"`
582583
IgnoreNames []string `mapstructure:"ignore-names"`
583584
IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
584585
IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`

pkg/golinters/varnamelen.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import (
1212
)
1313

1414
func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
15-
a := varnamelen.NewAnalyzer()
16-
15+
analyzer := varnamelen.NewAnalyzer()
1716
cfg := map[string]map[string]interface{}{}
17+
1818
if settings != nil {
1919
vnlCfg := map[string]interface{}{
2020
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
2121
"checkReturn": strconv.FormatBool(settings.CheckReturn),
22+
"checkTypeParam": strconv.FormatBool(settings.CheckTypeParam),
2223
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
2324
"ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
2425
"ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
@@ -33,13 +34,13 @@ func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
3334
vnlCfg["minNameLength"] = strconv.Itoa(settings.MinNameLength)
3435
}
3536

36-
cfg[a.Name] = vnlCfg
37+
cfg[analyzer.Name] = vnlCfg
3738
}
3839

3940
return goanalysis.NewLinter(
40-
a.Name,
41+
analyzer.Name,
4142
"checks that the length of a variable's name matches its scope",
42-
[]*analysis.Analyzer{a},
43+
[]*analysis.Analyzer{analyzer},
4344
cfg,
4445
).WithLoadMode(goanalysis.LoadModeTypesInfo)
4546
}

0 commit comments

Comments
 (0)