update ineffassign
This commit is contained in:
parent
15858c2fb0
commit
b0281e853e
2
go.mod
2
go.mod
@ -19,7 +19,7 @@ require (
|
|||||||
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee
|
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee
|
||||||
github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98
|
github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98
|
||||||
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547
|
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547
|
||||||
github.com/golangci/ineffassign v0.0.0-20180808204949-2ee8f2867dde
|
github.com/golangci/ineffassign v0.0.0-20180808204949-42439a7714cc
|
||||||
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217
|
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217
|
||||||
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca
|
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca
|
||||||
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770
|
github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770
|
||||||
|
8
go.sum
8
go.sum
@ -60,8 +60,8 @@ github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98 h1:ir6/L2ZOJfFrJlOT
|
|||||||
github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
|
github.com/golangci/gofmt v0.0.0-20181105071733-0b8337e80d98/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
|
||||||
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547 h1:qMomh8bv+kDazm1dSLZ9S3zZ2PJZMHL4ilfBjxFOlmI=
|
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547 h1:qMomh8bv+kDazm1dSLZ9S3zZ2PJZMHL4ilfBjxFOlmI=
|
||||||
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547/go.mod h1:0qUabqiIQgfmlAmulqxyiGkkyF6/tOGSnY2cnPVwrzU=
|
github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547/go.mod h1:0qUabqiIQgfmlAmulqxyiGkkyF6/tOGSnY2cnPVwrzU=
|
||||||
github.com/golangci/ineffassign v0.0.0-20180808204949-2ee8f2867dde h1:qEGp3ZF1Qw6TkbWKn6GdJ12Ssu/CpJBaBcJ4hrUjrSo=
|
github.com/golangci/ineffassign v0.0.0-20180808204949-42439a7714cc h1:XRFao922N8F3EcIXBSNX8Iywk+GI0dxD/8FicMX2D/c=
|
||||||
github.com/golangci/ineffassign v0.0.0-20180808204949-2ee8f2867dde/go.mod h1:e5tpTHCfVze+7EpLEozzMB3eafxo2KT5veNg1k6byQU=
|
github.com/golangci/ineffassign v0.0.0-20180808204949-42439a7714cc/go.mod h1:e5tpTHCfVze+7EpLEozzMB3eafxo2KT5veNg1k6byQU=
|
||||||
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217 h1:r7vyX+SN24x6+5AnpnrRn/bdwBb7U+McZqCHOVtXDuk=
|
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217 h1:r7vyX+SN24x6+5AnpnrRn/bdwBb7U+McZqCHOVtXDuk=
|
||||||
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg=
|
github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg=
|
||||||
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA=
|
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA=
|
||||||
@ -156,14 +156,14 @@ github.com/spf13/viper v1.0.2 h1:Ncr3ZIuJn322w2k1qmzXDnkLAdQMlJqBa9kfAH+irso=
|
|||||||
github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
|
github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
|
||||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb h1:lI9ufgFfvuqRctP9Ny8lDDLbSWCMxBPletcSqrnyFYM=
|
||||||
|
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
|
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
|
||||||
github.com/valyala/quicktemplate v1.1.1 h1:C58y/wN0FMTi2PR0n3onltemfFabany53j7M6SDDB8k=
|
github.com/valyala/quicktemplate v1.1.1 h1:C58y/wN0FMTi2PR0n3onltemfFabany53j7M6SDDB8k=
|
||||||
github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
|
github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
|
||||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||||
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb h1:lI9ufgFfvuqRctP9Ny8lDDLbSWCMxBPletcSqrnyFYM=
|
|
||||||
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U=
|
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U=
|
||||||
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
48
vendor/github.com/golangci/ineffassign/ineffassign.go
generated
vendored
48
vendor/github.com/golangci/ineffassign/ineffassign.go
generated
vendored
@ -240,7 +240,7 @@ func (bld *builder) Visit(n ast.Node) ast.Visitor {
|
|||||||
bld.use(id)
|
bld.use(id)
|
||||||
}
|
}
|
||||||
// Don't treat explicit initialization to zero as assignment; it is often used as shorthand for a bare declaration.
|
// Don't treat explicit initialization to zero as assignment; it is often used as shorthand for a bare declaration.
|
||||||
if n.Tok == token.DEFINE && i < len(n.Rhs) && isZeroLiteral(n.Rhs[i]) {
|
if n.Tok == token.DEFINE && i < len(n.Rhs) && isZeroInitializer(n.Rhs[i]) {
|
||||||
bld.use(id)
|
bld.use(id)
|
||||||
} else {
|
} else {
|
||||||
bld.assign(id)
|
bld.assign(id)
|
||||||
@ -278,18 +278,17 @@ func (bld *builder) Visit(n ast.Node) ast.Visitor {
|
|||||||
for _, x := range n.Results {
|
for _, x := range n.Results {
|
||||||
bld.walk(x)
|
bld.walk(x)
|
||||||
}
|
}
|
||||||
res := bld.results[len(bld.results)-1]
|
if res := bld.results[len(bld.results)-1]; res != nil {
|
||||||
if res == nil {
|
for _, f := range res.List {
|
||||||
break
|
for _, id := range f.Names {
|
||||||
}
|
if n.Results != nil {
|
||||||
for _, f := range res.List {
|
bld.assign(id)
|
||||||
for _, id := range f.Names {
|
}
|
||||||
if n.Results != nil {
|
bld.use(id)
|
||||||
bld.assign(id)
|
|
||||||
}
|
}
|
||||||
bld.use(id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bld.newBlock()
|
||||||
case *ast.SendStmt:
|
case *ast.SendStmt:
|
||||||
bld.maybePanic()
|
bld.maybePanic()
|
||||||
return bld
|
return bld
|
||||||
@ -350,15 +349,30 @@ func (bld *builder) Visit(n ast.Node) ast.Visitor {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isZeroLiteral(x ast.Expr) bool {
|
func isZeroInitializer(x ast.Expr) bool {
|
||||||
b, ok := x.(*ast.BasicLit)
|
// Assume that a call expression of a single argument is a conversion expression. We can't do better without type information.
|
||||||
if !ok {
|
if c, ok := x.(*ast.CallExpr); ok {
|
||||||
return false
|
switch c.Fun.(type) {
|
||||||
|
case *ast.Ident, *ast.SelectorExpr:
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(c.Args) != 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
x = c.Args[0]
|
||||||
}
|
}
|
||||||
switch b.Value {
|
|
||||||
case "0", "0.0", "0.", ".0", `""`:
|
switch x := x.(type) {
|
||||||
return true
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -92,7 +92,7 @@ github.com/golangci/gofmt/goimports
|
|||||||
# github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547
|
# github.com/golangci/gosec v0.0.0-20180901114220-66fb7fc33547
|
||||||
github.com/golangci/gosec
|
github.com/golangci/gosec
|
||||||
github.com/golangci/gosec/rules
|
github.com/golangci/gosec/rules
|
||||||
# github.com/golangci/ineffassign v0.0.0-20180808204949-2ee8f2867dde
|
# github.com/golangci/ineffassign v0.0.0-20180808204949-42439a7714cc
|
||||||
github.com/golangci/ineffassign
|
github.com/golangci/ineffassign
|
||||||
# github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217
|
# github.com/golangci/lint-1 v0.0.0-20180610141402-ee948d087217
|
||||||
github.com/golangci/lint-1
|
github.com/golangci/lint-1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user