Skip to content

Commit

Permalink
Bump wsl to v3.2.0 (golangci#1750)
Browse files Browse the repository at this point in the history
  • Loading branch information
bombsimon authored and ashanbrown committed Feb 20, 2021
1 parent ebf95bf commit 37dab60
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .golangci.example.yml
Expand Up @@ -411,6 +411,8 @@ linters-settings:
# Allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types. Default is true.
allow-assign-and-call: true
# Allow assignments to be cuddled with anything. Default is false.
allow-assign-and-anything: false
# Allow multiline assignments to be cuddled. Default is true.
allow-multiline-assign: true
# Allow declarations (var) to be cuddled.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -11,7 +11,7 @@ require (
github.com/ashanbrown/forbidigo v1.1.0
github.com/ashanbrown/makezero v0.0.0-20201205152432-7b7cdbb3025a
github.com/bkielbasa/cyclop v1.2.0
github.com/bombsimon/wsl/v3 v3.1.0
github.com/bombsimon/wsl/v3 v3.2.0
github.com/charithe/durationcheck v0.0.4
github.com/daixiang0/gci v0.2.8
github.com/denis-tingajkin/go-header v0.4.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum

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

2 changes: 2 additions & 0 deletions pkg/config/config.go
Expand Up @@ -350,6 +350,7 @@ type GocognitSettings struct {
type WSLSettings struct {
StrictAppend bool `mapstructure:"strict-append"`
AllowAssignAndCallCuddle bool `mapstructure:"allow-assign-and-call"`
AllowAssignAndAnythingCuddle bool `mapstructure:"allow-assign-and-anything"`
AllowMultiLineAssignCuddle bool `mapstructure:"allow-multiline-assign"`
AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
AllowTrailingComment bool `mapstructure:"allow-trailing-comment"`
Expand Down Expand Up @@ -491,6 +492,7 @@ var defaultLintersSettings = LintersSettings{
WSL: WSLSettings{
StrictAppend: true,
AllowAssignAndCallCuddle: true,
AllowAssignAndAnythingCuddle: false,
AllowMultiLineAssignCuddle: true,
AllowCuddleDeclaration: false,
AllowTrailingComment: false,
Expand Down
1 change: 1 addition & 0 deletions pkg/golinters/wsl.go
Expand Up @@ -39,6 +39,7 @@ func NewWSL() *goanalysis.Linter {
processorCfg = wsl.Configuration{
StrictAppend: linterCfg.StrictAppend,
AllowAssignAndCallCuddle: linterCfg.AllowAssignAndCallCuddle,
AllowAssignAndAnythingCuddle: linterCfg.AllowAssignAndAnythingCuddle,
AllowMultiLineAssignCuddle: linterCfg.AllowMultiLineAssignCuddle,
AllowCuddleDeclaration: linterCfg.AllowCuddleDeclaration,
AllowTrailingComment: linterCfg.AllowTrailingComment,
Expand Down
9 changes: 8 additions & 1 deletion test/testdata/wsl.go
Expand Up @@ -66,7 +66,14 @@ func main() {
"multiple",
)
if err != nil { // ERROR "if statements should only be cuddled with assignments used in the if statement itself"
panic(notErr)
panic("not from the line above")
}

// This is OK since we use a variable from the line above, even if we don't
// check it with the if.
xx := notErr
if err != nil {
panic(xx)
}
}

Expand Down

0 comments on commit 37dab60

Please sign in to comment.