From dd12fd9bb2ba9975cde9d10d74702bb911f3601f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 05:56:57 +0000 Subject: [PATCH] Bump github.com/kisielk/errcheck from 1.7.0 to 1.8.0 Bumps [github.com/kisielk/errcheck](https://github.com/kisielk/errcheck) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/kisielk/errcheck/releases) - [Commits](https://github.com/kisielk/errcheck/compare/v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: github.com/kisielk/errcheck dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../errcheck/errcheck/embedded_walker.go | 3 +- .../errcheck/errcheck/embedded_walker_121.go | 10 ++++ .../errcheck/errcheck/embedded_walker_122.go | 10 ++++ .../kisielk/errcheck/errcheck/errcheck.go | 50 ++++++++++++++----- .../kisielk/errcheck/errcheck/excludes.go | 5 ++ vendor/modules.txt | 2 +- 8 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_121.go create mode 100644 vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_122.go diff --git a/go.mod b/go.mod index c0266d51..944db6b2 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/cppforlife/go-cli-ui v0.0.0-20220428182907-73db60c7611a github.com/google/go-containerregistry v0.20.2 github.com/hashicorp/go-version v1.6.0 - github.com/kisielk/errcheck v1.7.0 + github.com/kisielk/errcheck v1.8.0 github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 golang.org/x/sync v0.8.0 diff --git a/go.sum b/go.sum index 45e40c93..f1aa81c1 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/errcheck v1.7.0 h1:+SbscKmWJ5mOK/bO1zS60F5I9WwZDWOfRsC4RwfwRV0= -github.com/kisielk/errcheck v1.7.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= +github.com/kisielk/errcheck v1.8.0 h1:ZX/URYa7ilESY19ik/vBmCn6zdGQLxACwjAcWbHlYlg= +github.com/kisielk/errcheck v1.8.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= diff --git a/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker.go b/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker.go index dff39179..98f28e9a 100644 --- a/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker.go +++ b/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker.go @@ -84,7 +84,8 @@ func walkThroughEmbeddedInterfaces(sel *types.Selection) ([]types.Type, bool) { } func getTypeAtFieldIndex(startingAt types.Type, fieldIndex int) types.Type { - t := maybeUnname(maybeDereference(startingAt)) + t := maybeDereference(maybeUnalias(startingAt)) + t = maybeUnname(maybeUnalias(t)) s, ok := t.(*types.Struct) if !ok { panic(fmt.Sprintf("cannot get Field of a type that is not a struct, got a %T", t)) diff --git a/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_121.go b/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_121.go new file mode 100644 index 00000000..f2df6849 --- /dev/null +++ b/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_121.go @@ -0,0 +1,10 @@ +//go:build !go1.22 +// +build !go1.22 + +package errcheck + +import "go/types" + +func maybeUnalias(t types.Type) types.Type { + return t +} diff --git a/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_122.go b/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_122.go new file mode 100644 index 00000000..cbff3cd4 --- /dev/null +++ b/vendor/github.com/kisielk/errcheck/errcheck/embedded_walker_122.go @@ -0,0 +1,10 @@ +//go:build go1.22 +// +build go1.22 + +package errcheck + +import "go/types" + +func maybeUnalias(t types.Type) types.Type { + return types.Unalias(t) +} diff --git a/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go b/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go index d61d348f..a7a2a30b 100644 --- a/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go +++ b/vendor/github.com/kisielk/errcheck/errcheck/errcheck.go @@ -80,7 +80,7 @@ func (r *Result) Append(other Result) { r.UncheckedErrors = append(r.UncheckedErrors, other.UncheckedErrors...) } -// Returns the unique errors that have been accumulated. Duplicates may occur +// Unique returns the unique errors that have been accumulated. Duplicates may occur // when a file containing an unchecked error belongs to > 1 package. // // The method receiver remains unmodified after the call to Unique. @@ -338,7 +338,7 @@ func (v *visitor) selectorName(call *ast.CallExpr) string { // then just that function's fullName is returned. // // Otherwise, we walk through all the potentially embedded interfaces of the receiver -// the collect a list of type-qualified function names that we will check. +// to collect a list of type-qualified function names that we will check. func (v *visitor) namesForExcludeCheck(call *ast.CallExpr) []string { sel, fn, ok := v.selectorAndFunc(call) if !ok { @@ -351,7 +351,7 @@ func (v *visitor) namesForExcludeCheck(call *ast.CallExpr) []string { } // This will be missing for functions without a receiver (like fmt.Printf), - // so just fall back to the the function's fullName in that case. + // so just fall back to the function's fullName in that case. selection, ok := v.typesInfo.Selections[sel] if !ok { return []string{name} @@ -420,9 +420,9 @@ func (v *visitor) ignoreCall(call *ast.CallExpr) bool { // 2. x.y.f() var id *ast.Ident switch exp := call.Fun.(type) { - case (*ast.Ident): + case *ast.Ident: id = exp - case (*ast.SelectorExpr): + case *ast.SelectorExpr: id = exp.Sel default: // eg: *ast.SliceExpr, *ast.IndexExpr @@ -586,26 +586,38 @@ func (v *visitor) Visit(node ast.Node) ast.Visitor { for _, name := range vspec.Names { lhs = append(lhs, ast.Expr(name)) } - v.checkAssignment(lhs, vspec.Values) + followed := v.checkAssignment(lhs, vspec.Values) + if !followed { + return nil + } } case *ast.AssignStmt: - v.checkAssignment(stmt.Lhs, stmt.Rhs) + followed := v.checkAssignment(stmt.Lhs, stmt.Rhs) + if !followed { + return nil + } + + case *ast.TypeAssertExpr: + v.checkAssertExpr(stmt) + return nil default: } return v } -func (v *visitor) checkAssignment(lhs, rhs []ast.Expr) { +// checkAssignment checks the assignment statement and returns a boolean value +// indicating whether to continue checking the substructure in AssignStmt or not +func (v *visitor) checkAssignment(lhs, rhs []ast.Expr) (followed bool) { if len(rhs) == 1 { // single value on rhs; check against lhs identifiers if call, ok := rhs[0].(*ast.CallExpr); ok { if !v.blank { - return + return true } if v.ignoreCall(call) { - return + return true } isError := v.errorsByArg(call) for i := 0; i < len(lhs); i++ { @@ -619,11 +631,11 @@ func (v *visitor) checkAssignment(lhs, rhs []ast.Expr) { } } else if assert, ok := rhs[0].(*ast.TypeAssertExpr); ok { if !v.asserts { - return + return false } if assert.Type == nil { // type switch - return + return false } if len(lhs) < 2 { // assertion result not read @@ -632,6 +644,7 @@ func (v *visitor) checkAssignment(lhs, rhs []ast.Expr) { // assertion result ignored v.addErrorAtPosition(id.NamePos, nil) } + return false } } else { // multiple value on rhs; in this case a call can't return @@ -661,6 +674,19 @@ func (v *visitor) checkAssignment(lhs, rhs []ast.Expr) { } } } + + return true +} + +func (v *visitor) checkAssertExpr(expr *ast.TypeAssertExpr) { + if !v.asserts { + return + } + if expr.Type == nil { + // type switch + return + } + v.addErrorAtPosition(expr.Pos(), nil) } func isErrorType(t types.Type) bool { diff --git a/vendor/github.com/kisielk/errcheck/errcheck/excludes.go b/vendor/github.com/kisielk/errcheck/errcheck/excludes.go index a783b5a7..450b798e 100644 --- a/vendor/github.com/kisielk/errcheck/errcheck/excludes.go +++ b/vendor/github.com/kisielk/errcheck/errcheck/excludes.go @@ -47,6 +47,11 @@ var DefaultExcludedSymbols = []string{ // hash "(hash.Hash).Write", + + // hash/maphash + "(*hash/maphash.Hash).Write", + "(*hash/maphash.Hash).WriteByte", + "(*hash/maphash.Hash).WriteString", } // ReadExcludes reads an excludes file, a newline delimited file that lists diff --git a/vendor/modules.txt b/vendor/modules.txt index d1e31283..a2b24745 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -87,7 +87,7 @@ github.com/inconshreveable/mousetrap # github.com/json-iterator/go v1.1.12 ## explicit; go 1.12 github.com/json-iterator/go -# github.com/kisielk/errcheck v1.7.0 +# github.com/kisielk/errcheck v1.8.0 ## explicit; go 1.18 github.com/kisielk/errcheck github.com/kisielk/errcheck/errcheck