Skip to content

Commit

Permalink
self-review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom committed Mar 3, 2024
1 parent 4ecbfc9 commit 249d252
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 33 deletions.
36 changes: 4 additions & 32 deletions internal/checkers/bool_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
arg1, ok1 := isComparisonWithTrue(pass, expr, token.EQL)
arg2, ok2 := isComparisonWithFalse(pass, expr, token.NEQ)

if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2) {
return nil
}
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2) {
return nil
}

survivingArg, ok := anyVal([]bool{ok1, ok2}, arg1, arg2)
if ok {
if ok && !isEmptyInterface(pass, survivingArg) {
return newNeedSimplifyDiagnostic(survivingArg, expr.Pos(), expr.End())
}
}
Expand All @@ -175,15 +168,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
arg2, ok2 := isComparisonWithFalse(pass, expr, token.EQL)
arg3, ok3 := isNegation(expr)

if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2, arg3) {
return nil
}
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2, arg3) {
return nil
}

survivingArg, ok := anyVal([]bool{ok1, ok2, ok3}, arg1, arg2, arg3)
if ok {
if ok && !isEmptyInterface(pass, survivingArg) {
return newUseFalseDiagnostic(survivingArg, expr.Pos(), expr.End())
}
}
Expand All @@ -198,15 +184,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
arg1, ok1 := isComparisonWithTrue(pass, expr, token.EQL)
arg2, ok2 := isComparisonWithFalse(pass, expr, token.NEQ)

if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2) {
return nil
}
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2) {
return nil
}

survivingArg, ok := anyVal([]bool{ok1, ok2}, arg1, arg2)
if ok {
if ok && !isEmptyInterface(pass, survivingArg) {
return newNeedSimplifyDiagnostic(survivingArg, expr.Pos(), expr.End())
}
}
Expand All @@ -216,15 +195,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
arg2, ok2 := isComparisonWithFalse(pass, expr, token.EQL)
arg3, ok3 := isNegation(expr)

if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2, arg3) {
return nil
}
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2, arg3) {
return nil
}

survivingArg, ok := anyVal([]bool{ok1, ok2, ok3}, arg1, arg2, arg3)
if ok {
if ok && !isEmptyInterface(pass, survivingArg) {
return newUseTrueDiagnostic(survivingArg, expr.Pos(), expr.End())
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func BindToFlags(cfg *Config, fs *flag.FlagSet) {
fs.Var(&cfg.EnabledCheckers, "enable", "comma separated list of enabled checkers (in addition to enabled by default)")

fs.BoolVar(&cfg.BoolCompare.IgnoreCustomTypes, "bool-compare.ignore-custom-types", false,
"ignore user defined types (over builtin `bool`)")
"ignore user defined types (over builtin bool)")
fs.Var(&cfg.ExpectedActual.ExpVarPattern, "expected-actual.pattern", "regexp for expected variable name")
fs.Var(&cfg.RequireError.FnPattern, "require-error.fn-pattern", "regexp for error assertions that should only be analyzed")
fs.Var(NewEnumValue(suiteExtraAssertCallModeAsString, &cfg.SuiteExtraAssertCall.Mode),
Expand Down

0 comments on commit 249d252

Please sign in to comment.