File tree 4 files changed +14
-0
lines changed
4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -3788,6 +3788,12 @@ linters:
3788
3788
# Defaults: [ "Unlock", "RUnlock" ]
3789
3789
allow-cuddle-with-rhs : [ "Foo", "Bar" ]
3790
3790
3791
+ # Allow cuddling with any block as long as the variable is used somewhere in
3792
+ # the block.
3793
+ # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-cuddle-used-in-block
3794
+ # Default: false
3795
+ allow-cuddle-used-in-block : true
3796
+
3791
3797
# Causes an error when an If statement that checks an error variable doesn't
3792
3798
# cuddle with the assignment of that variable.
3793
3799
# https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-err-cuddling
Original file line number Diff line number Diff line change 3954
3954
"type" : " string"
3955
3955
}
3956
3956
},
3957
+ "allow-cuddle-used-in-block" : {
3958
+ "description" : " Allow cuddling with any block as long as the variable is used somewhere in the block" ,
3959
+ "type" : " boolean" ,
3960
+ "default" : false
3961
+ },
3957
3962
"allow-multiline-assign" : {
3958
3963
"description" : " Allow multiline assignments to be cuddled." ,
3959
3964
"type" : " boolean" ,
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ var defaultLintersSettings = LintersSettings{
188
188
AllowCuddleDeclaration : false ,
189
189
AllowCuddleWithCalls : []string {"Lock" , "RLock" },
190
190
AllowCuddleWithRHS : []string {"Unlock" , "RUnlock" },
191
+ AllowCuddleUsedInBlock : false ,
191
192
ForceCuddleErrCheckAndAssign : false ,
192
193
ErrorVariableNames : []string {"err" },
193
194
ForceExclusiveShortDeclarations : false ,
@@ -972,6 +973,7 @@ type WSLSettings struct {
972
973
AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
973
974
AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"`
974
975
AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"`
976
+ AllowCuddleUsedInBlock bool `mapstructure:"allow-cuddle-used-in-block"`
975
977
ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"`
976
978
ErrorVariableNames []string `mapstructure:"error-variable-names"`
977
979
ForceExclusiveShortDeclarations bool `mapstructure:"force-short-decl-cuddling"`
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ func New(settings *config.WSLSettings) *goanalysis.Linter {
23
23
AllowCuddleWithCalls : settings .AllowCuddleWithCalls ,
24
24
AllowCuddleWithRHS : settings .AllowCuddleWithRHS ,
25
25
ForceCuddleErrCheckAndAssign : settings .ForceCuddleErrCheckAndAssign ,
26
+ AllowCuddleUsedInBlock : settings .AllowCuddleUsedInBlock ,
26
27
ErrorVariableNames : settings .ErrorVariableNames ,
27
28
ForceExclusiveShortDeclarations : settings .ForceExclusiveShortDeclarations ,
28
29
IncludeGenerated : true , // force to true because golangci-lint already have a way to filter generated files.
You can’t perform that action at this time.
0 commit comments