diff --git a/gocognit.go b/gocognit.go index e47bc3a..0687f5e 100644 --- a/gocognit.go +++ b/gocognit.go @@ -304,11 +304,6 @@ func (v *complexityVisitor) visitCallExpr(n *ast.CallExpr) ast.Visitor { if obj == v.name.Obj && name == v.name.Name { // called by same function directly (direct recursion) v.incComplexity() - } else if obj != nil { - if fnDecl, ok := obj.Decl.(*ast.FuncDecl); ok { - // called by same function indirectly (indirect recursion) - ast.Walk(v, fnDecl) - } } } return v diff --git a/testdata/src/a/a.go b/testdata/src/a/a.go index 115151c..9eb95a3 100644 --- a/testdata/src/a/a.go +++ b/testdata/src/a/a.go @@ -125,18 +125,6 @@ func FactRec(n int) int { // want "cognitive complexity 3 of func FactRec is hig } } // total complexity = 3 -func FactRecIndirect(n int) int { // want "cognitive complexity 3 of func FactRecIndirect is high \\(> 0\\)" - if n <= 1 { // +1 - return 1 - } else { // +1 - return factRecIndirect0(n) // +0 +1, due to indirect call to FactRecIndirect - } -} // total complexity = 3 - -func factRecIndirect0(n int) int { // want "cognitive complexity 3 of func factRecIndirect0 is high \\(> 0\\)" - return n * FactRecIndirect(n-1) // +0 +3 due to inderect call to factRecIndirect0 -} // total complexity = 3 - func FactLoop(n int) int { // want "cognitive complexity 1 of func FactLoop is high \\(> 0\\)" total := 1 for n > 0 { // +1 diff --git a/testdata/src/b/b.go b/testdata/src/b/b.go index 4517ab2..2bd3093 100644 --- a/testdata/src/b/b.go +++ b/testdata/src/b/b.go @@ -125,18 +125,6 @@ func FactRec(n int) int { } } // total complexity = 3 -func FactRecIndirect(n int) int { - if n <= 1 { // +1 - return 1 - } else { // +1 - return factRecIndirect0(n) // +0 +1, due to indirect call to FactRecIndirect - } -} // total complexity = 3 - -func factRecIndirect0(n int) int { - return n * FactRecIndirect(n-1) // +0 +3 due to inderect call to factRecIndirect0 -} // total complexity = 3 - func FactLoop(n int) int { total := 1 for n > 0 { // +1