aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/bombsimon
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-02-22 22:16:50 +0100
committerTaras Madan <tarasmadan@google.com>2023-02-24 12:47:23 +0100
commit4165372ec8fd142475a4e35fd0cf4f8042132208 (patch)
tree21cd62211b4dd80bee469054c5b65db77342333c /vendor/github.com/bombsimon
parent2b3ed821a493b8936c8bacfa6f8b4f1c90a00855 (diff)
dependencies: update
set go min requirements to 1.19 update dependencies update vendor
Diffstat (limited to 'vendor/github.com/bombsimon')
-rw-r--r--vendor/github.com/bombsimon/wsl/v3/.golangci.yml78
-rw-r--r--vendor/github.com/bombsimon/wsl/v3/.travis.yml25
-rw-r--r--vendor/github.com/bombsimon/wsl/v3/README.md4
-rw-r--r--vendor/github.com/bombsimon/wsl/v3/go.mod12
-rw-r--r--vendor/github.com/bombsimon/wsl/v3/go.sum25
-rw-r--r--vendor/github.com/bombsimon/wsl/v3/wsl.go49
6 files changed, 113 insertions, 80 deletions
diff --git a/vendor/github.com/bombsimon/wsl/v3/.golangci.yml b/vendor/github.com/bombsimon/wsl/v3/.golangci.yml
new file mode 100644
index 000000000..336ad4bc8
--- /dev/null
+++ b/vendor/github.com/bombsimon/wsl/v3/.golangci.yml
@@ -0,0 +1,78 @@
+---
+run:
+ deadline: 1m
+ issues-exit-code: 1
+ tests: true
+ skip-dirs:
+ - vendor$
+
+output:
+ format: colored-line-number
+ print-issued-lines: false
+
+linters-settings:
+ gocognit:
+ min-complexity: 10
+
+ depguard:
+ list-type: blacklist
+ include-go-root: false
+ packages:
+ - github.com/davecgh/go-spew/spew
+
+ misspell:
+ locale: US
+
+ gocritic:
+ # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run`
+ # to see all tags and checks. Empty list by default. See
+ # https://github.com/go-critic/go-critic#usage -> section "Tags".
+ enabled-tags:
+ - diagnostic
+ - experimental
+ - opinionated
+ - performance
+ - style
+
+linters:
+ enable-all: true
+ disable:
+ - cyclop
+ - deadcode
+ - dupl
+ - dupword
+ - exhaustivestruct
+ - exhaustruct
+ - forbidigo
+ - funlen
+ - gci
+ - gocognit
+ - gocyclo
+ - godox
+ - golint
+ - gomnd
+ - ifshort
+ - interfacer
+ - lll
+ - maintidx
+ - maligned
+ - nakedret
+ - nestif
+ - nlreturn
+ - nosnakecase
+ - paralleltest
+ - prealloc
+ - scopelint
+ - structcheck
+ - testpackage
+ - varcheck
+ - varnamelen
+ fast: false
+
+
+issues:
+ exclude-use-default: true
+ max-issues-per-linter: 0
+ max-same-issues: 0
+
+# vim: set sw=2 ts=2 et:
diff --git a/vendor/github.com/bombsimon/wsl/v3/.travis.yml b/vendor/github.com/bombsimon/wsl/v3/.travis.yml
deleted file mode 100644
index 5e2e26ed1..000000000
--- a/vendor/github.com/bombsimon/wsl/v3/.travis.yml
+++ /dev/null
@@ -1,25 +0,0 @@
----
-language: go
-
-go:
- - 1.13.x
- - 1.12.x
- - 1.11.x
-
-env:
- global:
- - GO111MODULE=on
-
-install:
- - go get -v golang.org/x/tools/cmd/cover github.com/mattn/goveralls
-
-script:
- - go test -v -covermode=count -coverprofile=coverage.out
-
-after_script:
- - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci
-
-notifications:
- email: false
-
-# vim: set ts=2 sw=2 et:
diff --git a/vendor/github.com/bombsimon/wsl/v3/README.md b/vendor/github.com/bombsimon/wsl/v3/README.md
index 9812f94a7..8ff74392b 100644
--- a/vendor/github.com/bombsimon/wsl/v3/README.md
+++ b/vendor/github.com/bombsimon/wsl/v3/README.md
@@ -3,7 +3,7 @@
[![forthebadge](https://forthebadge.com/images/badges/made-with-go.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
-[![Build Status](https://travis-ci.org/bombsimon/wsl.svg?branch=master)](https://travis-ci.org/bombsimon/wsl)
+[![GitHub Actions](https://github.com/bombsimon/wsl/actions/workflows/go.yml/badge.svg)](https://github.com/bombsimon/wsl/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/bombsimon/wsl/badge.svg?branch=master)](https://coveralls.io/github/bombsimon/wsl?branch=master)
WSL is a linter that enforces a very **non scientific** vision of how to make
@@ -28,7 +28,7 @@ make something configurable!
You can do that by using:
```sh
-go get -u github.com/bombsimon/wsl/cmd/...
+go get -u github.com/bombsimon/wsl/v3/cmd/...
```
### By golangci-lint (CI automation)
diff --git a/vendor/github.com/bombsimon/wsl/v3/go.mod b/vendor/github.com/bombsimon/wsl/v3/go.mod
deleted file mode 100644
index 0c325eda1..000000000
--- a/vendor/github.com/bombsimon/wsl/v3/go.mod
+++ /dev/null
@@ -1,12 +0,0 @@
-module github.com/bombsimon/wsl/v3
-
-go 1.12
-
-require (
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/kr/text v0.2.0 // indirect
- github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
- github.com/stretchr/testify v1.5.1
- gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
- gopkg.in/yaml.v2 v2.2.8 // indirect
-)
diff --git a/vendor/github.com/bombsimon/wsl/v3/go.sum b/vendor/github.com/bombsimon/wsl/v3/go.sum
deleted file mode 100644
index 3bdb59247..000000000
--- a/vendor/github.com/bombsimon/wsl/v3/go.sum
+++ /dev/null
@@ -1,25 +0,0 @@
-github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
-github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
-github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
-github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
-github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
-github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
-gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
-gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/bombsimon/wsl/v3/wsl.go b/vendor/github.com/bombsimon/wsl/v3/wsl.go
index 313b52787..1b139c047 100644
--- a/vendor/github.com/bombsimon/wsl/v3/wsl.go
+++ b/vendor/github.com/bombsimon/wsl/v3/wsl.go
@@ -5,12 +5,12 @@ import (
"go/ast"
"go/parser"
"go/token"
- "io/ioutil"
+ "os"
"reflect"
"strings"
)
-// Error reason strings
+// Error reason strings.
const (
reasonMustCuddleErrCheck = "if statements that check an error must be cuddled with the statement that assigned the error"
reasonOnlyCuddleIfWithAssign = "if statements should only be cuddled with assignments"
@@ -44,7 +44,7 @@ const (
reasonShortDeclNotExclusive = "short declaration should cuddle only with other short declarations"
)
-// Warning strings
+// Warning strings.
const (
warnTypeNotImplement = "type not implemented"
warnStmtNotImplemented = "stmt type not implemented"
@@ -176,7 +176,7 @@ type Configuration struct {
ForceExclusiveShortDeclarations bool
}
-// DefaultConfig returns default configuration
+// DefaultConfig returns default configuration.
func DefaultConfig() Configuration {
return Configuration{
StrictAppend: true,
@@ -216,6 +216,8 @@ type Processor struct {
}
// NewProcessor will create a Processor.
+//
+//nolint:gocritic // It's fine to copy config struct
func NewProcessorWithConfig(cfg Configuration) *Processor {
return &Processor{
result: []Result{},
@@ -230,10 +232,11 @@ func NewProcessor() *Processor {
// ProcessFiles takes a string slice with file names (full paths) and lints
// them.
-// nolint: gocritic
+//
+//nolint:gocritic // Don't want named returns
func (p *Processor) ProcessFiles(filenames []string) ([]Result, []string) {
for _, filename := range filenames {
- data, err := ioutil.ReadFile(filename)
+ data, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
@@ -247,7 +250,6 @@ func (p *Processor) ProcessFiles(filenames []string) ([]Result, []string) {
func (p *Processor) process(filename string, data []byte) {
fileSet := token.NewFileSet()
file, err := parser.ParseFile(fileSet, filename, data, parser.ParseComments)
-
// If the file is not parsable let's add a syntax error and move on.
if err != nil {
p.result = append(p.result, Result{
@@ -292,7 +294,6 @@ func (p *Processor) parseBlockBody(ident *ast.Ident, block *ast.BlockStmt) {
// parseBlockStatements will parse all the statements found in the body of a
// node. A list of Result is returned.
-// nolint: gocognit
func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
for i, stmt := range statements {
// Start by checking if this statement is another block (other than if,
@@ -335,7 +336,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
var calledOnLineAbove []string
// Check if the previous statement spans over multiple lines.
- var cuddledWithMultiLineAssignment = cuddledWithLastStmt && p.nodeStart(previousStatement) != p.nodeStart(stmt)-1
+ cuddledWithMultiLineAssignment := cuddledWithLastStmt && p.nodeStart(previousStatement) != p.nodeStart(stmt)-1
// Ensure previous line is not a multi line assignment and if not get
// rightAndLeftHandSide assigned variables.
@@ -397,8 +398,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
// t.X = true
// return t
// }
- // nolint: gocritic
- if i == len(statements)-1 && i == 1 {
+ if len(statements) == 2 && i == 1 {
if p.nodeEnd(stmt)-p.nodeStart(previousStatement) <= 2 {
return true
}
@@ -672,6 +672,22 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
continue
}
+ if c, ok := t.Call.Fun.(*ast.SelectorExpr); ok {
+ goCallArgs := append(p.findLHS(c.X), p.findRHS(c.X)...)
+
+ if atLeastOneInListsMatch(calledOnLineAbove, goCallArgs) {
+ continue
+ }
+ }
+
+ if c, ok := t.Call.Fun.(*ast.FuncLit); ok {
+ goCallArgs := append(p.findLHS(c.Body), p.findRHS(c.Body)...)
+
+ if atLeastOneInListsMatch(assignedOnLineAbove, goCallArgs) {
+ continue
+ }
+ }
+
if !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
p.addError(t.Pos(), reasonGoFuncWithoutAssign)
}
@@ -845,8 +861,7 @@ func (p *Processor) findRHS(node ast.Node) []string {
case *ast.BasicLit, *ast.SelectStmt, *ast.ChanType,
*ast.LabeledStmt, *ast.DeclStmt, *ast.BranchStmt,
*ast.TypeSpec, *ast.ArrayType, *ast.CaseClause,
- *ast.CommClause, *ast.KeyValueExpr, *ast.MapType,
- *ast.FuncLit:
+ *ast.CommClause, *ast.MapType, *ast.FuncLit:
// Nothing to add to RHS
case *ast.Ident:
return []string{t.Name}
@@ -905,6 +920,9 @@ func (p *Processor) findRHS(node ast.Node) []string {
rhs = append(rhs, p.findRHS(t.X)...)
rhs = append(rhs, p.findRHS(t.Low)...)
rhs = append(rhs, p.findRHS(t.High)...)
+ case *ast.KeyValueExpr:
+ rhs = p.findRHS(t.Key)
+ rhs = append(rhs, p.findRHS(t.Value)...)
default:
if x, ok := maybeX(t); ok {
return p.findRHS(x)
@@ -1002,7 +1020,6 @@ func atLeastOneInListsMatch(listOne, listTwo []string) bool {
// findLeadingAndTrailingWhitespaces will find leading and trailing whitespaces
// in a node. The method takes comments in consideration which will make the
// parser more gentle.
-// nolint: gocognit
func (p *Processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, nextStatement ast.Node) {
var (
allowedLinesBeforeFirstStatement = 1
@@ -1094,7 +1111,7 @@ func (p *Processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, ne
if seenCommentGroups > 1 {
allowedLinesBeforeFirstStatement += seenCommentGroups - 1
} else if seenCommentGroups == 1 {
- allowedLinesBeforeFirstStatement += 1
+ allowedLinesBeforeFirstStatement++
}
}
@@ -1205,7 +1222,7 @@ func (p *Processor) nodeStart(node ast.Node) int {
}
func (p *Processor) nodeEnd(node ast.Node) int {
- var line = p.fileSet.Position(node.End()).Line
+ line := p.fileSet.Position(node.End()).Line
if isEmptyLabeledStmt(node) {
return p.fileSet.Position(node.Pos()).Line