From b7aac3b1adf713b63d8e47cfb14ca65fde0ce9b7 Mon Sep 17 00:00:00 2001 From: Simon Sawert Date: Sat, 20 Feb 2021 15:16:10 +0100 Subject: [PATCH] Bump wsl to v3.2.0 (#1750) --- .golangci.example.yml | 2 ++ go.mod | 2 +- go.sum | 2 ++ pkg/config/config.go | 2 ++ pkg/golinters/wsl.go | 1 + test/testdata/wsl.go | 9 ++++++++- 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.golangci.example.yml b/.golangci.example.yml index a9ec5a75a17b..4f06698e2308 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -411,6 +411,8 @@ linters-settings: # Allow calls and assignments to be cuddled as long as the lines have any # matching variables, fields or types. Default is true. allow-assign-and-call: true + # Allow assignments to be cuddled with anything. Default is false. + allow-assign-and-anything: false # Allow multiline assignments to be cuddled. Default is true. allow-multiline-assign: true # Allow declarations (var) to be cuddled. diff --git a/go.mod b/go.mod index c4b1b75b22b9..14518a6a674a 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/ashanbrown/forbidigo v1.1.0 github.com/ashanbrown/makezero v0.0.0-20201205152432-7b7cdbb3025a github.com/bkielbasa/cyclop v1.2.0 - github.com/bombsimon/wsl/v3 v3.1.0 + github.com/bombsimon/wsl/v3 v3.2.0 github.com/charithe/durationcheck v0.0.4 github.com/daixiang0/gci v0.2.8 github.com/denis-tingajkin/go-header v0.4.2 diff --git a/go.sum b/go.sum index 5fa7b08d0b0a..70ad38f793f6 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,8 @@ github.com/bkielbasa/cyclop v1.2.0 h1:7Jmnh0yL2DjKfw28p86YTd/B4lRGcNuu12sKE35sM7 github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= github.com/bombsimon/wsl/v3 v3.1.0 h1:E5SRssoBgtVFPcYWUOFJEcgaySgdtTNYzsSKDOY7ss8= github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= +github.com/bombsimon/wsl/v3 v3.2.0 h1:x3QUbwW7tPGcCNridvqmhSRthZMTALnkg5/1J+vaUas= +github.com/bombsimon/wsl/v3 v3.2.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/charithe/durationcheck v0.0.4 h1:lD3ud3KJ2DaoL80EZ768cSBv3DS8Xr7nNgN+kgW1tts= github.com/charithe/durationcheck v0.0.4/go.mod h1:0oCYOIgY8Om3hZxPedxKn0mzy0rneKTWJhRm+r6Gl20= diff --git a/pkg/config/config.go b/pkg/config/config.go index 923087ca2f9d..0aae4914ecfd 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -350,6 +350,7 @@ type GocognitSettings struct { type WSLSettings struct { StrictAppend bool `mapstructure:"strict-append"` AllowAssignAndCallCuddle bool `mapstructure:"allow-assign-and-call"` + AllowAssignAndAnythingCuddle bool `mapstructure:"allow-assign-and-anything"` AllowMultiLineAssignCuddle bool `mapstructure:"allow-multiline-assign"` AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"` AllowTrailingComment bool `mapstructure:"allow-trailing-comment"` @@ -491,6 +492,7 @@ var defaultLintersSettings = LintersSettings{ WSL: WSLSettings{ StrictAppend: true, AllowAssignAndCallCuddle: true, + AllowAssignAndAnythingCuddle: false, AllowMultiLineAssignCuddle: true, AllowCuddleDeclaration: false, AllowTrailingComment: false, diff --git a/pkg/golinters/wsl.go b/pkg/golinters/wsl.go index ca659ac4e0e2..e5b8233bc04c 100644 --- a/pkg/golinters/wsl.go +++ b/pkg/golinters/wsl.go @@ -39,6 +39,7 @@ func NewWSL() *goanalysis.Linter { processorCfg = wsl.Configuration{ StrictAppend: linterCfg.StrictAppend, AllowAssignAndCallCuddle: linterCfg.AllowAssignAndCallCuddle, + AllowAssignAndAnythingCuddle: linterCfg.AllowAssignAndAnythingCuddle, AllowMultiLineAssignCuddle: linterCfg.AllowMultiLineAssignCuddle, AllowCuddleDeclaration: linterCfg.AllowCuddleDeclaration, AllowTrailingComment: linterCfg.AllowTrailingComment, diff --git a/test/testdata/wsl.go b/test/testdata/wsl.go index 0a50dafd5678..89fb5f732dd7 100644 --- a/test/testdata/wsl.go +++ b/test/testdata/wsl.go @@ -66,7 +66,14 @@ func main() { "multiple", ) if err != nil { // ERROR "if statements should only be cuddled with assignments used in the if statement itself" - panic(notErr) + panic("not from the line above") + } + + // This is OK since we use a variable from the line above, even if we don't + // check it with the if. + xx := notErr + if err != nil { + panic(xx) } }