1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00

fixes false positive in unconditional-recursion

This commit is contained in:
chavacava 2021-10-15 19:41:08 +00:00 committed by Minko Gechev
parent b331445a16
commit 55e1594efd
2 changed files with 12 additions and 1 deletions

View File

@ -61,8 +61,10 @@ func (w lintUnconditionalRecursionRule) Visit(node ast.Node) ast.Visitor {
case *ast.FuncDecl:
var rec *ast.Ident
switch {
case n.Recv == nil || n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1:
case n.Recv == nil:
rec = nil
case n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1:
rec = &ast.Ident{Name: "_"}
default:
rec = n.Recv.List[0].Names[0]
}

View File

@ -178,3 +178,12 @@ func urn17(ch chan int) {
}
urn17(ch) // MATCH /unconditional recursive call/
}
// Tests for #596
func (*fooType) BarFunc() {
BarFunc()
}
func (_ *fooType) BazFunc() {
BazFunc()
}