File tree 6 files changed +16
-2
lines changed 6 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -411,6 +411,8 @@ linters-settings:
411
411
# Allow calls and assignments to be cuddled as long as the lines have any
412
412
# matching variables, fields or types. Default is true.
413
413
allow-assign-and-call : true
414
+ # Allow assignments to be cuddled with anything. Default is false.
415
+ allow-assign-and-anything : false
414
416
# Allow multiline assignments to be cuddled. Default is true.
415
417
allow-multiline-assign : true
416
418
# Allow declarations (var) to be cuddled.
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ require (
11
11
github.com/ashanbrown/forbidigo v1.1.0
12
12
github.com/ashanbrown/makezero v0.0.0-20201205152432-7b7cdbb3025a
13
13
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
15
15
github.com/charithe/durationcheck v0.0.4
16
16
github.com/daixiang0/gci v0.2.8
17
17
github.com/denis-tingajkin/go-header v0.4.2
Original file line number Diff line number Diff line change @@ -350,6 +350,7 @@ type GocognitSettings struct {
350
350
type WSLSettings struct {
351
351
StrictAppend bool `mapstructure:"strict-append"`
352
352
AllowAssignAndCallCuddle bool `mapstructure:"allow-assign-and-call"`
353
+ AllowAssignAndAnythingCuddle bool `mapstructure:"allow-assign-and-anything"`
353
354
AllowMultiLineAssignCuddle bool `mapstructure:"allow-multiline-assign"`
354
355
AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
355
356
AllowTrailingComment bool `mapstructure:"allow-trailing-comment"`
@@ -491,6 +492,7 @@ var defaultLintersSettings = LintersSettings{
491
492
WSL : WSLSettings {
492
493
StrictAppend : true ,
493
494
AllowAssignAndCallCuddle : true ,
495
+ AllowAssignAndAnythingCuddle : false ,
494
496
AllowMultiLineAssignCuddle : true ,
495
497
AllowCuddleDeclaration : false ,
496
498
AllowTrailingComment : false ,
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ func NewWSL() *goanalysis.Linter {
39
39
processorCfg = wsl.Configuration {
40
40
StrictAppend : linterCfg .StrictAppend ,
41
41
AllowAssignAndCallCuddle : linterCfg .AllowAssignAndCallCuddle ,
42
+ AllowAssignAndAnythingCuddle : linterCfg .AllowAssignAndAnythingCuddle ,
42
43
AllowMultiLineAssignCuddle : linterCfg .AllowMultiLineAssignCuddle ,
43
44
AllowCuddleDeclaration : linterCfg .AllowCuddleDeclaration ,
44
45
AllowTrailingComment : linterCfg .AllowTrailingComment ,
Original file line number Diff line number Diff line change @@ -66,7 +66,14 @@ func main() {
66
66
"multiple" ,
67
67
)
68
68
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 )
70
77
}
71
78
}
72
79
You can’t perform that action at this time.
0 commit comments