Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump varnamelen from v0.3.0 to v0.4.0 #2348

Merged
merged 1 commit into from Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .golangci.example.yml
Expand Up @@ -697,9 +697,23 @@ linters-settings:
check-receiver: false
# Check named return values. (defaults to false)
check-return: false
# Ignore "ok" variables that hold the bool return value of a type assertion. (defaults to false)
ignore-type-assert-ok: false
# Ignore "ok" variables that hold the bool return value of a map index. (defaults to false)
ignore-map-index-ok: false
# Ignore "ok" variables that hold the bool return value of a channel receive. (defaults to false)
ignore-chan-recv-ok: false
# Optional list of variable names that should be ignored completely. (defaults to empty list)
ignore-names:
- err
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>".
ignore-decls:
- c echo.Context
- t testing.T
- f *foo.Bar
- e error
- i int

whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -13,7 +13,7 @@ require (
github.com/ashanbrown/forbidigo v1.2.0
github.com/ashanbrown/makezero v0.0.0-20210520155254-b6261585ddde
github.com/bkielbasa/cyclop v1.2.0
github.com/blizzy78/varnamelen v0.3.0
github.com/blizzy78/varnamelen v0.4.0
github.com/bombsimon/wsl/v3 v3.3.0
github.com/breml/bidichk v0.1.1
github.com/butuzov/ireturn v0.1.1
Expand Down
12 changes: 6 additions & 6 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions pkg/config/linters_settings.go
Expand Up @@ -486,11 +486,15 @@ type VarCheckSettings struct {
}

type VarnamelenSettings struct {
MaxDistance int `mapstructure:"max-distance"`
MinNameLength int `mapstructure:"min-name-length"`
CheckReceiver bool `mapstructure:"check-receiver"`
CheckReturn bool `mapstructure:"check-return"`
IgnoreNames []string `mapstructure:"ignore-names"`
MaxDistance int `mapstructure:"max-distance"`
MinNameLength int `mapstructure:"min-name-length"`
CheckReceiver bool `mapstructure:"check-receiver"`
CheckReturn bool `mapstructure:"check-return"`
IgnoreNames []string `mapstructure:"ignore-names"`
IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`
IgnoreChanRecvOk bool `mapstructure:"ignore-chan-recv-ok"`
IgnoreDecls []string `mapstructure:"ignore-decls"`
}

type WhitespaceSettings struct {
Expand Down
10 changes: 7 additions & 3 deletions pkg/golinters/varnamelen.go
Expand Up @@ -17,9 +17,13 @@ func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
cfg := map[string]map[string]interface{}{}
if settings != nil {
vnlCfg := map[string]interface{}{
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
"checkReturn": strconv.FormatBool(settings.CheckReturn),
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
"checkReturn": strconv.FormatBool(settings.CheckReturn),
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
"ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
"ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
"ignoreChanRecvOk": strconv.FormatBool(settings.IgnoreChanRecvOk),
"ignoreDecls": strings.Join(settings.IgnoreDecls, ","),
}

if settings.MaxDistance > 0 {
Expand Down