Skip to content

Commit 37dab60

Browse files
bombsimonashanbrown
authored andcommitted
Bump wsl to v3.2.0 (golangci#1750)
1 parent ebf95bf commit 37dab60

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

.golangci.example.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ linters-settings:
411411
# Allow calls and assignments to be cuddled as long as the lines have any
412412
# matching variables, fields or types. Default is true.
413413
allow-assign-and-call: true
414+
# Allow assignments to be cuddled with anything. Default is false.
415+
allow-assign-and-anything: false
414416
# Allow multiline assignments to be cuddled. Default is true.
415417
allow-multiline-assign: true
416418
# Allow declarations (var) to be cuddled.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/ashanbrown/forbidigo v1.1.0
1212
github.com/ashanbrown/makezero v0.0.0-20201205152432-7b7cdbb3025a
1313
github.com/bkielbasa/cyclop v1.2.0
14-
github.com/bombsimon/wsl/v3 v3.1.0
14+
github.com/bombsimon/wsl/v3 v3.2.0
1515
github.com/charithe/durationcheck v0.0.4
1616
github.com/daixiang0/gci v0.2.8
1717
github.com/denis-tingajkin/go-header v0.4.2

go.sum

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ type GocognitSettings struct {
350350
type WSLSettings struct {
351351
StrictAppend bool `mapstructure:"strict-append"`
352352
AllowAssignAndCallCuddle bool `mapstructure:"allow-assign-and-call"`
353+
AllowAssignAndAnythingCuddle bool `mapstructure:"allow-assign-and-anything"`
353354
AllowMultiLineAssignCuddle bool `mapstructure:"allow-multiline-assign"`
354355
AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
355356
AllowTrailingComment bool `mapstructure:"allow-trailing-comment"`
@@ -491,6 +492,7 @@ var defaultLintersSettings = LintersSettings{
491492
WSL: WSLSettings{
492493
StrictAppend: true,
493494
AllowAssignAndCallCuddle: true,
495+
AllowAssignAndAnythingCuddle: false,
494496
AllowMultiLineAssignCuddle: true,
495497
AllowCuddleDeclaration: false,
496498
AllowTrailingComment: false,

pkg/golinters/wsl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func NewWSL() *goanalysis.Linter {
3939
processorCfg = wsl.Configuration{
4040
StrictAppend: linterCfg.StrictAppend,
4141
AllowAssignAndCallCuddle: linterCfg.AllowAssignAndCallCuddle,
42+
AllowAssignAndAnythingCuddle: linterCfg.AllowAssignAndAnythingCuddle,
4243
AllowMultiLineAssignCuddle: linterCfg.AllowMultiLineAssignCuddle,
4344
AllowCuddleDeclaration: linterCfg.AllowCuddleDeclaration,
4445
AllowTrailingComment: linterCfg.AllowTrailingComment,

test/testdata/wsl.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ func main() {
6666
"multiple",
6767
)
6868
if err != nil { // ERROR "if statements should only be cuddled with assignments used in the if statement itself"
69-
panic(notErr)
69+
panic("not from the line above")
70+
}
71+
72+
// This is OK since we use a variable from the line above, even if we don't
73+
// check it with the if.
74+
xx := notErr
75+
if err != nil {
76+
panic(xx)
7077
}
7178
}
7279

0 commit comments

Comments
 (0)