Skip to content

Commit

Permalink
terence's review
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas committed May 23, 2021
1 parent f47d858 commit 2e5ec37
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tools/analyzers/interfacechecker/analyzer.go
Expand Up @@ -4,6 +4,7 @@ package interfacechecker
import (
"errors"
"go/ast"
"go/token"
"go/types"
"strings"

Expand Down Expand Up @@ -82,12 +83,15 @@ func handleConditionalExpression(exp *ast.BinaryExpr, pass *analysis.Pass) {
continue
}
if xIsIface && yIsNil {
pass.Reportf(identX.Pos(), "A nilness check is being performed on an interface"+
", this check needs another accompanying check on the underlying object for the interface")
reportFailure(identX.Pos(), pass)
}
if yisIface && xIsNil {
pass.Reportf(identY.Pos(), "A nilness check is being performed on an interface"+
", this check needs another accompanying check on the underlying object for the interface")
reportFailure(identY.Pos(), pass)
}
}
}

func reportFailure(pos token.Pos, pass *analysis.Pass) {
pass.Reportf(pos, "A single nilness check is being performed on an interface"+
", this check needs another accompanying nilness check on the underlying object for the interface.")
}

0 comments on commit 2e5ec37

Please sign in to comment.