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:
parent
b331445a16
commit
55e1594efd
@ -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]
|
||||
}
|
||||
|
9
testdata/unconditional-recursion.go
vendored
9
testdata/unconditional-recursion.go
vendored
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user