Skip to content

Commit 249d252

Browse files
committed
self-review fixes
1 parent 4ecbfc9 commit 249d252

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

internal/checkers/bool_compare.go

+4-32
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
157157
arg1, ok1 := isComparisonWithTrue(pass, expr, token.EQL)
158158
arg2, ok2 := isComparisonWithFalse(pass, expr, token.NEQ)
159159

160-
if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2) {
161-
return nil
162-
}
163-
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2) {
164-
return nil
165-
}
166-
167160
survivingArg, ok := anyVal([]bool{ok1, ok2}, arg1, arg2)
168-
if ok {
161+
if ok && !isEmptyInterface(pass, survivingArg) {
169162
return newNeedSimplifyDiagnostic(survivingArg, expr.Pos(), expr.End())
170163
}
171164
}
@@ -175,15 +168,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
175168
arg2, ok2 := isComparisonWithFalse(pass, expr, token.EQL)
176169
arg3, ok3 := isNegation(expr)
177170

178-
if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2, arg3) {
179-
return nil
180-
}
181-
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2, arg3) {
182-
return nil
183-
}
184-
185171
survivingArg, ok := anyVal([]bool{ok1, ok2, ok3}, arg1, arg2, arg3)
186-
if ok {
172+
if ok && !isEmptyInterface(pass, survivingArg) {
187173
return newUseFalseDiagnostic(survivingArg, expr.Pos(), expr.End())
188174
}
189175
}
@@ -198,15 +184,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
198184
arg1, ok1 := isComparisonWithTrue(pass, expr, token.EQL)
199185
arg2, ok2 := isComparisonWithFalse(pass, expr, token.NEQ)
200186

201-
if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2) {
202-
return nil
203-
}
204-
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2) {
205-
return nil
206-
}
207-
208187
survivingArg, ok := anyVal([]bool{ok1, ok2}, arg1, arg2)
209-
if ok {
188+
if ok && !isEmptyInterface(pass, survivingArg) {
210189
return newNeedSimplifyDiagnostic(survivingArg, expr.Pos(), expr.End())
211190
}
212191
}
@@ -216,15 +195,8 @@ func (checker BoolCompare) Check(pass *analysis.Pass, call *CallMeta) *analysis.
216195
arg2, ok2 := isComparisonWithFalse(pass, expr, token.EQL)
217196
arg3, ok3 := isNegation(expr)
218197

219-
if anyCondSatisfaction(pass, isEmptyInterface, arg1, arg2, arg3) {
220-
return nil
221-
}
222-
if anyCondSatisfaction(pass, isBoolOverride, arg1, arg2, arg3) {
223-
return nil
224-
}
225-
226198
survivingArg, ok := anyVal([]bool{ok1, ok2, ok3}, arg1, arg2, arg3)
227-
if ok {
199+
if ok && !isEmptyInterface(pass, survivingArg) {
228200
return newUseTrueDiagnostic(survivingArg, expr.Pos(), expr.End())
229201
}
230202
}

internal/config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func BindToFlags(cfg *Config, fs *flag.FlagSet) {
9898
fs.Var(&cfg.EnabledCheckers, "enable", "comma separated list of enabled checkers (in addition to enabled by default)")
9999

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

0 commit comments

Comments
 (0)