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

Commit 740c8ac

Browse files
author
Eugene Simonov
committed
Fix issue #13
1 parent 4f6df33 commit 740c8ac

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/analyzer/occurrences.go

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ func (nom namedOccurrenceMap) addFromCondition(stmt *ast.IfStmt) {
187187
case *ast.BinaryExpr:
188188
for _, v := range [2]ast.Expr{v.X, v.Y} {
189189
switch e := v.(type) {
190+
case *ast.CallExpr:
191+
nom.addFromCallExpr(stmt.If, e)
190192
case *ast.Ident:
191193
nom.addFromIdent(stmt.If, e)
192194
case *ast.SelectorExpr:

testdata/testdata.go

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ func notUsed_CondIdent_NotOK() {
4949
}
5050
}
5151

52+
func notUsed_CondCallWithIndentExpr_NotOK() {
53+
v := getInt() // want "variable '.+' is only used in the if-statement"
54+
if int(v) != 2 {
55+
}
56+
}
57+
5258
func notUsed_Body_NotOK() {
5359
v := getValue() // want "variable '.+' is only used in the if-statement"
5460
if true {

0 commit comments

Comments
 (0)