File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -299,13 +299,16 @@ func (v *complexityVisitor) visitBinaryExpr(n *ast.BinaryExpr) ast.Visitor {
299
299
}
300
300
301
301
func (v * complexityVisitor ) visitCallExpr (n * ast.CallExpr ) ast.Visitor {
302
- if name , ok := n .Fun .(* ast.Ident ); ok {
303
- if name .Obj == v .name .Obj && name .Name == v .name .Name {
302
+ if callIdent , ok := n .Fun .(* ast.Ident ); ok {
303
+ obj , name := callIdent .Obj , callIdent .Name
304
+ if obj == v .name .Obj && name == v .name .Name {
304
305
// called by same function directly (direct recursion)
305
306
v .incComplexity ()
306
- } else if fnDecl , ok := name .Obj .Decl .(* ast.FuncDecl ); ok {
307
- // called by same function indirectly (indirect recursion)
308
- ast .Walk (v , fnDecl )
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
+ }
309
312
}
310
313
}
311
314
return v
Original file line number Diff line number Diff line change 7
7
)
8
8
9
9
func HelloWorld () string {
10
+ _ = len ("hello" )
10
11
return "Hello, World!"
11
12
} // total complexity = 0
12
13
Original file line number Diff line number Diff line change 7
7
)
8
8
9
9
func HelloWorld () string {
10
+ _ = len ("hello" )
10
11
return "Hello, World!"
11
12
} // total complexity = 0
12
13
You can’t perform that action at this time.
0 commit comments