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.6.2 to v0.8.0 #2703

Merged
merged 1 commit into from Mar 30, 2022
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: 11 additions & 3 deletions .golangci.example.yml
Expand Up @@ -1473,12 +1473,15 @@ linters-settings:
# Variable names that are at least this long will be ignored.
# Default: 3
min-name-length: 2
# Check method receiver names.
# Check method receivers.
# Default: false
check-receiver: true
# Check named return values.
# Default: false
check-return: true
# Check type parameters.
# Default: false
check-type-param: true
# Ignore "ok" variables that hold the bool return value of a type assertion.
# Default: false
ignore-type-assert-ok: true
Expand All @@ -1493,8 +1496,11 @@ linters-settings:
ignore-names:
- err
# Optional list of variable declarations that should be ignored completely.
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>"
# for variables, or "const <name>" for constants.
# Entries must be in one of the following forms (see below for examples):
# - for variables, parameters, named return values, method receivers, or type parameters:
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
# - for constants: const <name>
#
# Default: []
ignore-decls:
- c echo.Context
Expand All @@ -1503,6 +1509,8 @@ linters-settings:
- e error
- i int
- const C
- T any
- m map[string]int

whitespace:
# 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.3.0
github.com/ashanbrown/makezero v1.1.1
github.com/bkielbasa/cyclop v1.2.0
github.com/blizzy78/varnamelen v0.6.2
github.com/blizzy78/varnamelen v0.8.0
github.com/bombsimon/wsl/v3 v3.3.0
github.com/breml/bidichk v0.2.3
github.com/breml/errchkjson v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum

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

1 change: 1 addition & 0 deletions pkg/config/linters_settings.go
Expand Up @@ -579,6 +579,7 @@ type VarnamelenSettings struct {
MinNameLength int `mapstructure:"min-name-length"`
CheckReceiver bool `mapstructure:"check-receiver"`
CheckReturn bool `mapstructure:"check-return"`
CheckTypeParam bool `mapstructure:"check-type-param"`
IgnoreNames []string `mapstructure:"ignore-names"`
IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`
Expand Down
11 changes: 6 additions & 5 deletions pkg/golinters/varnamelen.go
Expand Up @@ -12,13 +12,14 @@ import (
)

func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
a := varnamelen.NewAnalyzer()

analyzer := varnamelen.NewAnalyzer()
cfg := map[string]map[string]interface{}{}

if settings != nil {
vnlCfg := map[string]interface{}{
"checkReceiver": strconv.FormatBool(settings.CheckReceiver),
"checkReturn": strconv.FormatBool(settings.CheckReturn),
"checkTypeParam": strconv.FormatBool(settings.CheckTypeParam),
"ignoreNames": strings.Join(settings.IgnoreNames, ","),
"ignoreTypeAssertOk": strconv.FormatBool(settings.IgnoreTypeAssertOk),
"ignoreMapIndexOk": strconv.FormatBool(settings.IgnoreMapIndexOk),
Expand All @@ -33,13 +34,13 @@ func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter {
vnlCfg["minNameLength"] = strconv.Itoa(settings.MinNameLength)
}

cfg[a.Name] = vnlCfg
cfg[analyzer.Name] = vnlCfg
}

return goanalysis.NewLinter(
a.Name,
analyzer.Name,
"checks that the length of a variable's name matches its scope",
[]*analysis.Analyzer{a},
[]*analysis.Analyzer{analyzer},
cfg,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}