Skip to content

Commit 16f84d2

Browse files
committed
Removed support for indirect recursion
1 parent db50331 commit 16f84d2

File tree

3 files changed

+0
-29
lines changed

3 files changed

+0
-29
lines changed

gocognit.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,6 @@ func (v *complexityVisitor) visitCallExpr(n *ast.CallExpr) ast.Visitor {
304304
if obj == v.name.Obj && name == v.name.Name {
305305
// called by same function directly (direct recursion)
306306
v.incComplexity()
307-
} else if obj != nil {
308-
if fnDecl, ok := obj.Decl.(*ast.FuncDecl); ok {
309-
// called by same function indirectly (indirect recursion)
310-
ast.Walk(v, fnDecl)
311-
}
312307
}
313308
}
314309
return v

testdata/src/a/a.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,6 @@ func FactRec(n int) int { // want "cognitive complexity 3 of func FactRec is hig
125125
}
126126
} // total complexity = 3
127127

128-
func FactRecIndirect(n int) int { // want "cognitive complexity 3 of func FactRecIndirect is high \\(> 0\\)"
129-
if n <= 1 { // +1
130-
return 1
131-
} else { // +1
132-
return factRecIndirect0(n) // +0 +1, due to indirect call to FactRecIndirect
133-
}
134-
} // total complexity = 3
135-
136-
func factRecIndirect0(n int) int { // want "cognitive complexity 3 of func factRecIndirect0 is high \\(> 0\\)"
137-
return n * FactRecIndirect(n-1) // +0 +3 due to inderect call to factRecIndirect0
138-
} // total complexity = 3
139-
140128
func FactLoop(n int) int { // want "cognitive complexity 1 of func FactLoop is high \\(> 0\\)"
141129
total := 1
142130
for n > 0 { // +1

testdata/src/b/b.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,6 @@ func FactRec(n int) int {
125125
}
126126
} // total complexity = 3
127127

128-
func FactRecIndirect(n int) int {
129-
if n <= 1 { // +1
130-
return 1
131-
} else { // +1
132-
return factRecIndirect0(n) // +0 +1, due to indirect call to FactRecIndirect
133-
}
134-
} // total complexity = 3
135-
136-
func factRecIndirect0(n int) int {
137-
return n * FactRecIndirect(n-1) // +0 +3 due to inderect call to factRecIndirect0
138-
} // total complexity = 3
139-
140128
func FactLoop(n int) int {
141129
total := 1
142130
for n > 0 { // +1

0 commit comments

Comments
 (0)