From 5af04704f7e0b8fd1f0bcbef2f4b2e9dd6215280 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Feb 2025 01:17:16 +0000 Subject: [PATCH 1/3] build(deps): bump github.com/bombsimon/wsl/v4 from 4.5.0 to 4.6.0 Bumps [github.com/bombsimon/wsl/v4](https://github.com/bombsimon/wsl) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/bombsimon/wsl/releases) - [Commits](https://github.com/bombsimon/wsl/compare/v4.5.0...v4.6.0) --- updated-dependencies: - dependency-name: github.com/bombsimon/wsl/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index faba42dbd1a0..c2ef531ab1dc 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/ashanbrown/makezero v1.2.0 github.com/bkielbasa/cyclop v1.2.3 github.com/blizzy78/varnamelen v0.8.0 - github.com/bombsimon/wsl/v4 v4.5.0 + github.com/bombsimon/wsl/v4 v4.6.0 github.com/breml/bidichk v0.3.2 github.com/breml/errchkjson v0.4.0 github.com/butuzov/ireturn v0.3.1 diff --git a/go.sum b/go.sum index 1e7eadc9ee2a..52ae5f3fc34f 100644 --- a/go.sum +++ b/go.sum @@ -94,8 +94,8 @@ github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5 github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo= github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= -github.com/bombsimon/wsl/v4 v4.5.0 h1:iZRsEvDdyhd2La0FVi5k6tYehpOR/R7qIUjmKk7N74A= -github.com/bombsimon/wsl/v4 v4.5.0/go.mod h1:NOQ3aLF4nD7N5YPXMruR6ZXDOAqLoM0GEpLwTdvmOSc= +github.com/bombsimon/wsl/v4 v4.6.0 h1:ew2R/N42su553DKTYqt3HSxaQN+uHQPv4xZ2MBmwaW4= +github.com/bombsimon/wsl/v4 v4.6.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg= github.com/breml/bidichk v0.3.2 h1:xV4flJ9V5xWTqxL+/PMFF6dtJPvZLPsyixAoPe8BGJs= github.com/breml/bidichk v0.3.2/go.mod h1:VzFLBxuYtT23z5+iVkamXO386OB+/sVwZOpIj6zXGos= github.com/breml/errchkjson v0.4.0 h1:gftf6uWZMtIa/Is3XJgibewBm2ksAQSY/kABDNFTAdk= From 6caa10fe25e851d7e86ef7ab0ce83ba8445c2854 Mon Sep 17 00:00:00 2001 From: Simon Sawert Date: Fri, 28 Feb 2025 19:18:36 +0100 Subject: [PATCH 2/3] Add new configuration option --- .golangci.next.reference.yml | 6 ++++++ jsonschema/golangci.next.jsonschema.json | 5 +++++ pkg/config/linters_settings.go | 2 ++ pkg/golinters/wsl/wsl.go | 1 + 4 files changed, 14 insertions(+) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 6e6dff421716..1685b9e72ae6 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -3788,6 +3788,12 @@ linters: # Defaults: [ "Unlock", "RUnlock" ] allow-cuddle-with-rhs: [ "Foo", "Bar" ] + # Allow cuddling with any block as long as the variable is used somewhere in + # the block. + # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#allow-cuddle-used-in-block + # Default: false + allow-cuddle-used-in-block: true + # Causes an error when an If statement that checks an error variable doesn't # cuddle with the assignment of that variable. # https://github.com/bombsimon/wsl/blob/HEAD/doc/configuration.md#force-err-cuddling diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index f51e5e86eb23..686de7d66405 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -3954,6 +3954,11 @@ "type": "string" } }, + "allow-cuddle-used-in-block": { + "description": "Allow cuddling with any block as long as the variable is used somewhere in the block", + "type": "boolean", + "default": false + }, "allow-multiline-assign": { "description": "Allow multiline assignments to be cuddled.", "type": "boolean", diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 27b67d66da26..db18a564306b 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -188,6 +188,7 @@ var defaultLintersSettings = LintersSettings{ AllowCuddleDeclaration: false, AllowCuddleWithCalls: []string{"Lock", "RLock"}, AllowCuddleWithRHS: []string{"Unlock", "RUnlock"}, + AllowCuddleUsedInBlock: false, ForceCuddleErrCheckAndAssign: false, ErrorVariableNames: []string{"err"}, ForceExclusiveShortDeclarations: false, @@ -972,6 +973,7 @@ type WSLSettings struct { AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"` AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"` AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"` + AllowCuddleUsedInBlock bool `mapstructure:"allow-cuddle-used-in-block"` ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"` ErrorVariableNames []string `mapstructure:"error-variable-names"` ForceExclusiveShortDeclarations bool `mapstructure:"force-short-decl-cuddling"` diff --git a/pkg/golinters/wsl/wsl.go b/pkg/golinters/wsl/wsl.go index 2f71f342e781..12148627eb5b 100644 --- a/pkg/golinters/wsl/wsl.go +++ b/pkg/golinters/wsl/wsl.go @@ -23,6 +23,7 @@ func New(settings *config.WSLSettings) *goanalysis.Linter { AllowCuddleWithCalls: settings.AllowCuddleWithCalls, AllowCuddleWithRHS: settings.AllowCuddleWithRHS, ForceCuddleErrCheckAndAssign: settings.ForceCuddleErrCheckAndAssign, + AllowCuddleUsedInBlock: settings.AllowCuddleUsedInBlock, ErrorVariableNames: settings.ErrorVariableNames, ForceExclusiveShortDeclarations: settings.ForceExclusiveShortDeclarations, IncludeGenerated: true, // force to true because golangci-lint already have a way to filter generated files. From b349579fe6c603ab1127e4cf659c2aa8d006e6c3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 12 Mar 2025 19:52:57 +0100 Subject: [PATCH 3/3] chore: update --- jsonschema/golangci.jsonschema.json | 5 +++++ pkg/commands/internal/migrate/versiontwo/linters_settings.go | 1 + 2 files changed, 6 insertions(+) diff --git a/jsonschema/golangci.jsonschema.json b/jsonschema/golangci.jsonschema.json index f51e5e86eb23..686de7d66405 100644 --- a/jsonschema/golangci.jsonschema.json +++ b/jsonschema/golangci.jsonschema.json @@ -3954,6 +3954,11 @@ "type": "string" } }, + "allow-cuddle-used-in-block": { + "description": "Allow cuddling with any block as long as the variable is used somewhere in the block", + "type": "boolean", + "default": false + }, "allow-multiline-assign": { "description": "Allow multiline assignments to be cuddled.", "type": "boolean", diff --git a/pkg/commands/internal/migrate/versiontwo/linters_settings.go b/pkg/commands/internal/migrate/versiontwo/linters_settings.go index 2fe5051699bb..3461620e20f7 100644 --- a/pkg/commands/internal/migrate/versiontwo/linters_settings.go +++ b/pkg/commands/internal/migrate/versiontwo/linters_settings.go @@ -749,6 +749,7 @@ type WSLSettings struct { AllowCuddleDeclaration *bool `yaml:"allow-cuddle-declarations,omitempty" toml:"allow-cuddle-declarations,multiline,omitempty"` AllowCuddleWithCalls []string `yaml:"allow-cuddle-with-calls,omitempty" toml:"allow-cuddle-with-calls,multiline,omitempty"` AllowCuddleWithRHS []string `yaml:"allow-cuddle-with-rhs,omitempty" toml:"allow-cuddle-with-rhs,multiline,omitempty"` + AllowCuddleUsedInBlock *bool `yaml:"allow-cuddle-used-in-block,omitempty" toml:"allow-cuddle-used-in-block,multiline,omitempty"` ForceCuddleErrCheckAndAssign *bool `yaml:"force-err-cuddling,omitempty" toml:"force-err-cuddling,multiline,omitempty"` ErrorVariableNames []string `yaml:"error-variable-names,omitempty" toml:"error-variable-names,multiline,omitempty"` ForceExclusiveShortDeclarations *bool `yaml:"force-short-decl-cuddling,omitempty" toml:"force-short-decl-cuddling,multiline,omitempty"`