Skip to content

Commit 425cfc9

Browse files
blizzy78SeigeC
authored andcommitted
bump varnamelen to v0.4.0 (golangci#2348)
1 parent 59f60f5 commit 425cfc9

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
@@ -702,9 +702,23 @@ linters-settings:
702702
check-receiver: false
703703
# Check named return values. (defaults to false)
704704
check-return: false
705+
# Ignore "ok" variables that hold the bool return value of a type assertion. (defaults to false)
706+
ignore-type-assert-ok: false
707+
# Ignore "ok" variables that hold the bool return value of a map index. (defaults to false)
708+
ignore-map-index-ok: false
709+
# Ignore "ok" variables that hold the bool return value of a channel receive. (defaults to false)
710+
ignore-chan-recv-ok: false
705711
# Optional list of variable names that should be ignored completely. (defaults to empty list)
706712
ignore-names:
707713
- err
714+
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
715+
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>".
716+
ignore-decls:
717+
- c echo.Context
718+
- t testing.T
719+
- f *foo.Bar
720+
- e error
721+
- i int
708722

709723
whitespace:
710724
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)