Skip to content

Commit 1b53520

Browse files
authored
bump varnamelen to v0.4.0 (#2348)
1 parent 054fc3f commit 1b53520

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

.golangci.example.yml

+14
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,23 @@ linters-settings:
697697
check-receiver: false
698698
# Check named return values. (defaults to false)
699699
check-return: false
700+
# Ignore "ok" variables that hold the bool return value of a type assertion. (defaults to false)
701+
ignore-type-assert-ok: false
702+
# Ignore "ok" variables that hold the bool return value of a map index. (defaults to false)
703+
ignore-map-index-ok: false
704+
# Ignore "ok" variables that hold the bool return value of a channel receive. (defaults to false)
705+
ignore-chan-recv-ok: false
700706
# Optional list of variable names that should be ignored completely. (defaults to empty list)
701707
ignore-names:
702708
- err
709+
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
710+
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>".
711+
ignore-decls:
712+
- c echo.Context
713+
- t testing.T
714+
- f *foo.Bar
715+
- e error
716+
- i int
703717

704718
whitespace:
705719
multi-if: false # 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.2.0
1414
github.com/ashanbrown/makezero v0.0.0-20210520155254-b6261585ddde
1515
github.com/bkielbasa/cyclop v1.2.0
16-
github.com/blizzy78/varnamelen v0.3.0
16+
github.com/blizzy78/varnamelen v0.4.0
1717
github.com/bombsimon/wsl/v3 v3.3.0
1818
github.com/breml/bidichk v0.1.1
1919
github.com/butuzov/ireturn v0.1.1

go.sum

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

pkg/config/linters_settings.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,15 @@ type VarCheckSettings struct {
486486
}
487487

488488
type VarnamelenSettings struct {
489-
MaxDistance int `mapstructure:"max-distance"`
490-
MinNameLength int `mapstructure:"min-name-length"`
491-
CheckReceiver bool `mapstructure:"check-receiver"`
492-
CheckReturn bool `mapstructure:"check-return"`
493-
IgnoreNames []string `mapstructure:"ignore-names"`
489+
MaxDistance int `mapstructure:"max-distance"`
490+
MinNameLength int `mapstructure:"min-name-length"`
491+
CheckReceiver bool `mapstructure:"check-receiver"`
492+
CheckReturn bool `mapstructure:"check-return"`
493+
IgnoreNames []string `mapstructure:"ignore-names"`
494+
IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
495+
IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`
496+
IgnoreChanRecvOk bool `mapstructure:"ignore-chan-recv-ok"`
497+
IgnoreDecls []string `mapstructure:"ignore-decls"`
494498
}
495499

496500
type WhitespaceSettings struct {

pkg/golinters/varnamelen.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
1717
cfg := map[string]map[string]interface{}{}
1818
if settings != nil {
1919
vnlCfg := map[string]interface{}{
20-
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
21-
"checkReturn": strconv.FormatBool(settings.CheckReturn),
22-
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
20+
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
21+
"checkReturn": strconv.FormatBool(settings.CheckReturn),
22+
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
23+
"ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
24+
"ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
25+
"ignoreChanRecvOk": strconv.FormatBool(settings.IgnoreChanRecvOk),
26+
"ignoreDecls": strings.Join(settings.IgnoreDecls, ","),
2327
}
2428

2529
if settings.MaxDistance > 0 {

0 commit comments

Comments
 (0)