Skip to content

Commit

Permalink
fix: literal calls case
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Sep 26, 2023
1 parent 70ceb1c commit 6a67ee8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rule/unconditional-recursion.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ func (w lintUnconditionalRecursionRule) Visit(node ast.Node) ast.Visitor {
}
// unconditional loop
return w
}
case *ast.FuncLit:
return nil // literal call (closure) is not an issue
}

return w
}
Expand Down
7 changes: 7 additions & 0 deletions testdata/unconditional-recursion.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,10 @@ func (*fooType) BarFunc() {
func (_ *fooType) BazFunc() {
BazFunc()
}

// Tests for #902
func falsePositiveFuncLiteral() {
_ = foo(func() {
falsePositiveFuncLiteral()
})
}

0 comments on commit 6a67ee8

Please sign in to comment.