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 @@ -3788,6 +3788,12 @@ linters:
37883788 # Defaults: [ "Unlock", "RUnlock" ]
37893789 allow-cuddle-with-rhs : [ "Foo", "Bar" ]
37903790
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+
37913797 # Causes an error when an If statement that checks an error variable doesn't
37923798 # cuddle with the assignment of that variable.
37933799 # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-err-cuddling
Original file line number Diff line number Diff line change 39543954 "type" : " string"
39553955 }
39563956 },
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+ },
39573962 "allow-multiline-assign" : {
39583963 "description" : " Allow multiline assignments to be cuddled." ,
39593964 "type" : " boolean" ,
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ var defaultLintersSettings = LintersSettings{
188188 AllowCuddleDeclaration : false ,
189189 AllowCuddleWithCalls : []string {"Lock" , "RLock" },
190190 AllowCuddleWithRHS : []string {"Unlock" , "RUnlock" },
191+ AllowCuddleUsedInBlock : false ,
191192 ForceCuddleErrCheckAndAssign : false ,
192193 ErrorVariableNames : []string {"err" },
193194 ForceExclusiveShortDeclarations : false ,
@@ -972,6 +973,7 @@ type WSLSettings struct {
972973 AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
973974 AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"`
974975 AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"`
976+ AllowCuddleUsedInBlock bool `mapstructure:"allow-cuddle-used-in-block"`
975977 ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"`
976978 ErrorVariableNames []string `mapstructure:"error-variable-names"`
977979 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