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

wsl: fix force-err-cuddling flag #3407

Merged
merged 1 commit into from
Dec 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1928,15 +1928,15 @@ linters-settings:

# Causes an error when an If statement that checks an error variable doesn't
# cuddle with the assignment of that variable.
enforce-err-cuddling: false
force-err-cuddling: false

# When enforce-err-cuddling is enabled this is a list of names
# When force-err-cuddling is enabled this is a list of names
# used for error variables to check for in the conditional.
error-variable-names: [ "err" ]

# Causes an error if a short declaration (:=) cuddles with anything other than
# another short declaration.
# This logic overrides enforce-err-cuddling among others.
# This logic overrides force-err-cuddling among others.
force-short-decl-cuddling: false

# The custom section can be used to define linter plugins to be loaded at runtime.
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ type WSLSettings struct {
AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"`
AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"`
ForceCuddleErrCheckAndAssign bool `mapstructure:"enforce-err-cuddling"`
ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"`
ErrorVariableNames []string `mapstructure:"error-variable-names"`
ForceExclusiveShortDeclarations bool `mapstructure:"force-short-decl-cuddling"`
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/golinters/wsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func NewWSL(settings *config.WSLSettings) *goanalysis.Linter {
conf.AllowCuddleDeclaration = settings.AllowCuddleDeclaration
conf.AllowCuddleWithCalls = settings.AllowCuddleWithCalls
conf.AllowCuddleWithRHS = settings.AllowCuddleWithRHS
conf.ForceCuddleErrCheckAndAssign = settings.ForceCuddleErrCheckAndAssign
conf.ErrorVariableNames = settings.ErrorVariableNames
conf.ForceExclusiveShortDeclarations = settings.ForceExclusiveShortDeclarations
}

analyzer := &analysis.Analyzer{
Expand Down