aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/tomarrell
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-04-02 14:37:40 +0000
committerTaras Madan <tarasmadan@google.com>2024-04-03 09:59:40 +0000
commit9d2a90af8850a414d2da20b806d7aa8fd9a297ae (patch)
treeb6ce5a1bc2ecaed9f94b06b36eca20b98929970c /vendor/github.com/tomarrell
parentb90978ba49e3321a2d1cd77c07c196b088c97386 (diff)
mod: bump github.com/golangci/golangci-lint from 1.56.2 to 1.57.2
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.56.2 to 1.57.2. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.56.2...v1.57.2) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/tomarrell')
-rw-r--r--vendor/github.com/tomarrell/wrapcheck/v2/wrapcheck/wrapcheck.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/tomarrell/wrapcheck/v2/wrapcheck/wrapcheck.go b/vendor/github.com/tomarrell/wrapcheck/v2/wrapcheck/wrapcheck.go
index 6da17bd86..79e7bba86 100644
--- a/vendor/github.com/tomarrell/wrapcheck/v2/wrapcheck/wrapcheck.go
+++ b/vendor/github.com/tomarrell/wrapcheck/v2/wrapcheck/wrapcheck.go
@@ -121,7 +121,20 @@ func run(cfg WrapcheckConfig) func(*analysis.Pass) (interface{}, error) {
}
for _, file := range pass.Files {
+ // Keep track of parents so that can can traverse upwards to check for
+ // FuncDecls and FuncLits.
+ var parents []ast.Node
+
ast.Inspect(file, func(n ast.Node) bool {
+ if n == nil {
+ // Pop, since we're done with this node and its children.
+ parents = parents[:len(parents)-1]
+ } else {
+ // Push this node on the stack, since its children will be visited
+ // next.
+ parents = append(parents, n)
+ }
+
ret, ok := n.(*ast.ReturnStmt)
if !ok {
return true
@@ -137,6 +150,17 @@ func run(cfg WrapcheckConfig) func(*analysis.Pass) (interface{}, error) {
// to handle it by checking the return params of the function.
retFn, ok := expr.(*ast.CallExpr)
if ok {
+ // If you go up, and the parent is a FuncLit, then don't report an
+ // error as you are in an anonymous function. If you are inside a
+ // FuncDecl, then continue as normal.
+ for i := len(parents) - 1; i > 0; i-- {
+ if _, ok := parents[i].(*ast.FuncLit); ok {
+ return true
+ } else if _, ok := parents[i].(*ast.FuncDecl); ok {
+ break
+ }
+ }
+
// If the return type of the function is a single error. This will not
// match an error within multiple return values, for that, the below
// tuple check is required.