diff --git a/pkg/analyzer/analyzer.go b/pkg/analyzer/analyzer.go index 16217a1..36bb8d1 100644 --- a/pkg/analyzer/analyzer.go +++ b/pkg/analyzer/analyzer.go @@ -183,6 +183,7 @@ func (nom namedOccurrenceMap) checkExpression(candidate ast.Expr, ifPos token.Po for _, arg := range v.Args { nom.checkExpression(arg, ifPos) } + nom.checkExpression(v.Fun, ifPos) if fun, ok := v.Fun.(*ast.SelectorExpr); ok { nom.checkExpression(fun.X, ifPos) } diff --git a/testdata/testdata.go b/testdata/testdata.go index 973a694..8e51325 100644 --- a/testdata/testdata.go +++ b/testdata/testdata.go @@ -87,6 +87,14 @@ func notUsed_DeferStmt_OK() { defer noOp2(v) } +func notUsed_FuncDecl_OK(a func()) { + v := a + if v == nil { + return + } + v() +} + func notUsed_IfStmt_CondBinaryExpr_OK() { v := getValue() if v != nil {