File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -3885,6 +3885,12 @@ linters-settings:
38853885 # Defaults: [ "Unlock", "RUnlock" ]
38863886 allow-cuddle-with-rhs : [ "Foo", "Bar" ]
38873887
3888+ # Allow cuddling with any block as long as the variable is used somewhere in
3889+ # the block.
3890+ # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-cuddle-used-in-block
3891+ # Default: false
3892+ allow-cuddle-used-in-block : true
3893+
38883894 # Causes an error when an If statement that checks an error variable doesn't
38893895 # cuddle with the assignment of that variable.
38903896 # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-err-cuddling
Original file line number Diff line number Diff line change 37823782 "type" : " string"
37833783 }
37843784 },
3785+ "allow-cuddle-used-in-block" : {
3786+ "description" : " Allow cuddling with any block as long as the variable is used somewhere in the block" ,
3787+ "type" : " boolean" ,
3788+ "default" : false
3789+ },
37853790 "allow-multiline-assign" : {
37863791 "description" : " Allow multiline assignments to be cuddled." ,
37873792 "type" : " boolean" ,
Original file line number Diff line number Diff line change @@ -207,6 +207,7 @@ var defaultLintersSettings = LintersSettings{
207207 AllowCuddleDeclaration : false ,
208208 AllowCuddleWithCalls : []string {"Lock" , "RLock" },
209209 AllowCuddleWithRHS : []string {"Unlock" , "RUnlock" },
210+ AllowCuddleUsedInBlock : false ,
210211 ForceCuddleErrCheckAndAssign : false ,
211212 ErrorVariableNames : []string {"err" },
212213 ForceExclusiveShortDeclarations : false ,
@@ -1082,6 +1083,7 @@ type WSLSettings struct {
10821083 AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
10831084 AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"`
10841085 AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"`
1086+ AllowCuddleUsedInBlock bool `mapstructure:"allow-cuddle-used-in-block"`
10851087 ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"`
10861088 ErrorVariableNames []string `mapstructure:"error-variable-names"`
10871089 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 {
2323 AllowCuddleWithCalls : settings .AllowCuddleWithCalls ,
2424 AllowCuddleWithRHS : settings .AllowCuddleWithRHS ,
2525 ForceCuddleErrCheckAndAssign : settings .ForceCuddleErrCheckAndAssign ,
26+ AllowCuddleUsedInBlock : settings .AllowCuddleUsedInBlock ,
2627 ErrorVariableNames : settings .ErrorVariableNames ,
2728 ForceExclusiveShortDeclarations : settings .ForceExclusiveShortDeclarations ,
2829 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