Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Commit

Permalink
Handle func declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
esimonov committed Feb 20, 2021
1 parent 17e1ecd commit 67b6923
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 67b6923

Please sign in to comment.