Imports #
"go/ast"
"go/token"
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"
"go/ast"
"go/token"
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"
var Analyzer = *ast.UnaryExpr
const Doc = "check for common mistakes involving boolean operators"
var and = boolOp{...}
var or = boolOp{...}
type boolOp struct {
name string
tok token.Token
badEq token.Token
}
checkRedundant checks for expressions of the form e && e e || e Exprs must contain only side effect free expressions.
func (op boolOp) checkRedundant(pass *analysis.Pass, exprs []ast.Expr)
checkSuspect checks for expressions of the form x != c1 || x != c2 x == c1 && x == c2 where c1 and c2 are constant expressions. If c1 and c2 are the same then it's redundant; if c1 and c2 are different then it's always true or always false. Exprs must contain only side effect free expressions.
func (op boolOp) checkSuspect(pass *analysis.Pass, exprs []ast.Expr)
commutativeSets returns all side effect free sets of expressions in e that are connected by op. For example, given 'a || b || f() || c || d' with the or op, commutativeSets returns {{b, a}, {d, c}}. commutativeSets adds any expanded BinaryExprs to seen.
func (op boolOp) commutativeSets(info *types.Info, e *ast.BinaryExpr, seen map[*ast.BinaryExpr]bool) [][]ast.Expr
func run(pass *analysis.Pass) (interface{}, error)
split returns a slice of all subexpressions in e that are connected by op. For example, given 'a || (b || c) || d' with the or op, split returns []{d, c, b, a}. seen[e] is already true; any newly processed exprs are added to seen.
func (op boolOp) split(e ast.Expr, seen map[*ast.BinaryExpr]bool) (exprs []ast.Expr)
Generated with Arrow