diff --git a/go.mod b/go.mod index b5f9e77e4..428a1c1b4 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/go-xorm/core v0.6.2 // indirect github.com/go-xorm/xorm v0.7.9 // indirect github.com/golang/protobuf v1.3.2 // indirect - github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc + github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf github.com/imdario/mergo v0.3.7 github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jgautheron/goconst v0.0.0-20200227150835-cda7ea3bf591 diff --git a/go.sum b/go.sum index 5dcc1b9e3..258debf57 100644 --- a/go.sum +++ b/go.sum @@ -147,6 +147,8 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc h1:cJlkeAx1QYgO5N80aF5xRGstVsRQwgLR7uA2FnP1ZjY= github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf h1:vc7Dmrk4JwS0ZPS6WZvWlwDflgDTA26jItmbSj83nug= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= diff --git a/vendor/github.com/gordonklaus/ineffassign/README.md b/vendor/github.com/gordonklaus/ineffassign/README.md index 6dcb9f0cc..5d6730695 100644 --- a/vendor/github.com/gordonklaus/ineffassign/README.md +++ b/vendor/github.com/gordonklaus/ineffassign/README.md @@ -1,4 +1,4 @@ # ineffassign Detect ineffectual assignments in Go code. -This tool misses some cases because does not consider any type information in its analysis. (For example, assignments to struct fields are never marked as ineffectual.) It should, however, never give any false positives. +This tool misses some cases because it does not consider any type information in its analysis. (For example, assignments to struct fields are never marked as ineffectual.) It should, however, never give any false positives. diff --git a/vendor/github.com/gordonklaus/ineffassign/ineffassign.go b/vendor/github.com/gordonklaus/ineffassign/ineffassign.go index d067bc418..ce4a4f3fd 100644 --- a/vendor/github.com/gordonklaus/ineffassign/ineffassign.go +++ b/vendor/github.com/gordonklaus/ineffassign/ineffassign.go @@ -282,18 +282,17 @@ func (bld *builder) Visit(n ast.Node) ast.Visitor { for _, x := range n.Results { bld.walk(x) } - res := bld.results[len(bld.results)-1] - if res == nil { - break - } - for _, f := range res.List { - for _, id := range f.Names { - if n.Results != nil { - bld.assign(id) + if res := bld.results[len(bld.results)-1]; res != nil { + for _, f := range res.List { + for _, id := range f.Names { + if n.Results != nil { + bld.assign(id) + } + bld.use(id) } - bld.use(id) } } + bld.newBlock() case *ast.SendStmt: bld.maybePanic() return bld @@ -368,14 +367,16 @@ func isZeroInitializer(x ast.Expr) bool { x = c.Args[0] } - b, ok := x.(*ast.BasicLit) - if !ok { - return false - } - switch b.Value { - case "0", "0.0", "0.", ".0", `""`: - return true + switch x := x.(type) { + case *ast.BasicLit: + switch x.Value { + case "0", "0.0", "0.", ".0", `""`: + return true + } + case *ast.Ident: + return x.Name == "false" && x.Obj == nil } + return false } diff --git a/vendor/modules.txt b/vendor/modules.txt index 0f35381fe..d7c342b69 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -74,7 +74,7 @@ github.com/go-sql-driver/mysql github.com/go-testfixtures/testfixtures/v3 # github.com/golang/protobuf v1.3.2 github.com/golang/protobuf/proto -# github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc +# github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf github.com/gordonklaus/ineffassign # github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/hcl