From 28bde765fa9744bed639a9c86796b9e3d21f0240 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 16:07:35 +0000 Subject: [PATCH] Bump github.com/kisielk/errcheck from 1.6.2 to 1.6.3 Bumps [github.com/kisielk/errcheck](https://github.com/kisielk/errcheck) from 1.6.2 to 1.6.3. - [Release notes](https://github.com/kisielk/errcheck/releases) - [Commits](https://github.com/kisielk/errcheck/compare/v1.6.2...v1.6.3) --- updated-dependencies: - dependency-name: github.com/kisielk/errcheck dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/kisielk/errcheck/README.md | 10 +- .../kisielk/errcheck/errcheck/errcheck.go | 141 +++++++++++------- vendor/modules.txt | 2 +- 5 files changed, 96 insertions(+), 63 deletions(-) diff --git a/go.mod b/go.mod index 40a2eecb..218cad90 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/cppforlife/go-cli-ui v0.0.0-20220428182907-73db60c7611a github.com/google/go-containerregistry v0.12.1 github.com/hashicorp/go-version v1.6.0 - github.com/kisielk/errcheck v1.6.2 + github.com/kisielk/errcheck v1.6.3 github.com/spf13/cobra v1.6.1 github.com/stretchr/testify v1.8.1 github.com/vmware-tanzu/carvel-imgpkg v0.35.0 diff --git a/go.sum b/go.sum index f19216fa..659d1c28 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/k14s/semver/v4 v4.0.1-0.20210701191048-266d47ac6115 h1:wKSifC/VbCaQMqXYn6/gSFqle82OX4bE3KYALDU9FlU= github.com/k14s/semver/v4 v4.0.1-0.20210701191048-266d47ac6115/go.mod h1:mGrnmO5qnhJIaSiwMo05cvRL6Ww9ccYbTgNFcm6RHZQ= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/errcheck v1.6.2 h1:uGQ9xI8/pgc9iOoCe7kWQgRE6SBTrCGmTSf0LrEtY7c= -github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= +github.com/kisielk/errcheck v1.6.3 h1:dEKh+GLHcWm2oN34nMvDzn1sqI0i0WxPvrgiJA5JuM8= +github.com/kisielk/errcheck v1.6.3/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= diff --git a/vendor/github.com/kisielk/errcheck/README.md b/vendor/github.com/kisielk/errcheck/README.md index 0155a0d9..10755acc 100644 --- a/vendor/github.com/kisielk/errcheck/README.md +++ b/vendor/github.com/kisielk/errcheck/README.md @@ -10,6 +10,8 @@ errcheck is a program for checking for unchecked errors in go programs. errcheck requires Go 1.12 or newer, and depends on the package go/packages from the golang.org/x/tools repository. +errcheck requires module support to be enabled, which is the default in Go 1.13 and later. If installing with Go 1.12 you will need to specify `GO111MODULE=on` if building within `$GOPATH`. + ## Use For basic usage, just give the package path of interest as the first argument: @@ -20,7 +22,7 @@ To check all packages beneath the current directory: errcheck ./... -Or check all packages in your $GOPATH and $GOROOT: +Or check all packages in your `$GOPATH` and `$GOROOT`: errcheck all @@ -36,6 +38,10 @@ takes no arguments. The `-blank` flag enables checking for assignments of errors to the blank identifier. It takes no arguments. +The `-abspath` flag prints the absolute paths to files with unchecked errors. + +The `-mod` flag sets the module download mode to use: `readonly` or `vendor`. + ### go/analysis The package provides `Analyzer` instance that can be used with @@ -120,6 +126,8 @@ specified for it. To disable this, specify a regex that matches nothing: The `-ignoretests` flag disables checking of `_test.go` files. It takes no arguments. +The `-ignoregenerated` flag disables checking of generated source code. It takes no arguments. + ## Exit Codes errcheck returns 1 if any problems were found in the checked files. diff --git a/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go b/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go index 0a4067f9..a5ee3711 100644 --- a/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go +++ b/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go @@ -569,73 +569,98 @@ func (v *visitor) Visit(node ast.Node) ast.Visitor { if !v.ignoreCall(stmt.Call) && v.callReturnsError(stmt.Call) { v.addErrorAtPosition(stmt.Call.Lparen, stmt.Call) } + case *ast.GenDecl: + if stmt.Tok != token.VAR { + break + } + + for _, spec := range stmt.Specs { + vspec := spec.(*ast.ValueSpec) + + if len(vspec.Values) == 0 { + // ignore declarations w/o assignments + continue + } + + var lhs []ast.Expr + for _, name := range vspec.Names { + lhs = append(lhs, ast.Expr(name)) + } + v.checkAssignment(lhs, vspec.Values) + } + case *ast.AssignStmt: - if len(stmt.Rhs) == 1 { - // single value on rhs; check against lhs identifiers - if call, ok := stmt.Rhs[0].(*ast.CallExpr); ok { - if !v.blank { - break - } - if v.ignoreCall(call) { - break - } - isError := v.errorsByArg(call) - for i := 0; i < len(stmt.Lhs); i++ { - if id, ok := stmt.Lhs[i].(*ast.Ident); ok { - // We shortcut calls to recover() because errorsByArg can't - // check its return types for errors since it returns interface{}. - if id.Name == "_" && (v.isRecover(call) || isError[i]) { - v.addErrorAtPosition(id.NamePos, call) - } + v.checkAssignment(stmt.Lhs, stmt.Rhs) + + default: + } + return v +} + +func (v *visitor) checkAssignment(lhs, rhs []ast.Expr) { + if len(rhs) == 1 { + // single value on rhs; check against lhs identifiers + if call, ok := rhs[0].(*ast.CallExpr); ok { + if !v.blank { + return + } + if v.ignoreCall(call) { + return + } + isError := v.errorsByArg(call) + for i := 0; i < len(lhs); i++ { + if id, ok := lhs[i].(*ast.Ident); ok { + // We shortcut calls to recover() because errorsByArg can't + // check its return types for errors since it returns interface{}. + if id.Name == "_" && (v.isRecover(call) || isError[i]) { + v.addErrorAtPosition(id.NamePos, call) } } - } else if assert, ok := stmt.Rhs[0].(*ast.TypeAssertExpr); ok { - if !v.asserts { - break - } - if assert.Type == nil { - // type switch - break - } - if len(stmt.Lhs) < 2 { - // assertion result not read - v.addErrorAtPosition(stmt.Rhs[0].Pos(), nil) - } else if id, ok := stmt.Lhs[1].(*ast.Ident); ok && v.blank && id.Name == "_" { - // assertion result ignored - v.addErrorAtPosition(id.NamePos, nil) - } } - } else { - // multiple value on rhs; in this case a call can't return - // multiple values. Assume len(stmt.Lhs) == len(stmt.Rhs) - for i := 0; i < len(stmt.Lhs); i++ { - if id, ok := stmt.Lhs[i].(*ast.Ident); ok { - if call, ok := stmt.Rhs[i].(*ast.CallExpr); ok { - if !v.blank { - continue - } - if v.ignoreCall(call) { - continue - } - if id.Name == "_" && v.callReturnsError(call) { - v.addErrorAtPosition(id.NamePos, call) - } - } else if assert, ok := stmt.Rhs[i].(*ast.TypeAssertExpr); ok { - if !v.asserts { - continue - } - if assert.Type == nil { - // Shouldn't happen anyway, no multi assignment in type switches - continue - } - v.addErrorAtPosition(id.NamePos, nil) + } else if assert, ok := rhs[0].(*ast.TypeAssertExpr); ok { + if !v.asserts { + return + } + if assert.Type == nil { + // type switch + return + } + if len(lhs) < 2 { + // assertion result not read + v.addErrorAtPosition(rhs[0].Pos(), nil) + } else if id, ok := lhs[1].(*ast.Ident); ok && v.blank && id.Name == "_" { + // assertion result ignored + v.addErrorAtPosition(id.NamePos, nil) + } + } + } else { + // multiple value on rhs; in this case a call can't return + // multiple values. Assume len(lhs) == len(rhs) + for i := 0; i < len(lhs); i++ { + if id, ok := lhs[i].(*ast.Ident); ok { + if call, ok := rhs[i].(*ast.CallExpr); ok { + if !v.blank { + continue + } + if v.ignoreCall(call) { + continue + } + if id.Name == "_" && v.callReturnsError(call) { + v.addErrorAtPosition(id.NamePos, call) + } + } else if assert, ok := rhs[i].(*ast.TypeAssertExpr); ok { + if !v.asserts { + continue } + if assert.Type == nil { + // Shouldn't happen anyway, no multi assignment in type switches + continue + } + v.addErrorAtPosition(id.NamePos, nil) } } } - default: } - return v } func isErrorType(t types.Type) bool { diff --git a/vendor/modules.txt b/vendor/modules.txt index b7a352d4..f0989b32 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -68,7 +68,7 @@ github.com/json-iterator/go # github.com/k14s/semver/v4 v4.0.1-0.20210701191048-266d47ac6115 ## explicit; go 1.14 github.com/k14s/semver/v4 -# github.com/kisielk/errcheck v1.6.2 +# github.com/kisielk/errcheck v1.6.3 ## explicit; go 1.14 github.com/kisielk/errcheck github.com/kisielk/errcheck/errcheck