Skip to content

Commit 288a599

Browse files
blizzy78SeigeC
authored andcommitted
bump varnamelen to v0.8.0 (golangci#2703)
1 parent 76d6685 commit 288a599

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
@@ -1498,12 +1498,15 @@ linters-settings:
14981498
# Variable names that are at least this long will be ignored.
14991499
# Default: 3
15001500
min-name-length: 2
1501-
# Check method receiver names.
1501+
# Check method receivers.
15021502
# Default: false
15031503
check-receiver: true
15041504
# Check named return values.
15051505
# Default: false
15061506
check-return: true
1507+
# Check type parameters.
1508+
# Default: false
1509+
check-type-param: true
15071510
# Ignore "ok" variables that hold the bool return value of a type assertion.
15081511
# Default: false
15091512
ignore-type-assert-ok: true
@@ -1518,8 +1521,11 @@ linters-settings:
15181521
ignore-names:
15191522
- err
15201523
# Optional list of variable declarations that should be ignored completely.
1521-
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>"
1522-
# for variables, or "const <name>" for constants.
1524+
# Entries must be in one of the following forms (see below for examples):
1525+
# - for variables, parameters, named return values, method receivers, or type parameters:
1526+
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
1527+
# - for constants: const <name>
1528+
#
15231529
# Default: []
15241530
ignore-decls:
15251531
- c echo.Context
@@ -1528,6 +1534,8 @@ linters-settings:
15281534
- e error
15291535
- i int
15301536
- const C
1537+
- T any
1538+
- m map[string]int
15311539

15321540
whitespace:
15331541
# 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)