Skip to content

Commit c98cc07

Browse files
committed
simple: don't flag S1002 in tests
Closes gh-320
1 parent 717f185 commit c98cc07

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

simple/lint.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ func (c *Checker) LintIfBoolCmp(j *lint.Job) {
221221
if (l1-len(r))%2 == 1 {
222222
r = "!" + r
223223
}
224+
if IsInTest(j, node) {
225+
return true
226+
}
224227
j.Errorf(expr, "should omit comparison to bool constant, can be simplified to %s", r)
225228
return true
226229
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package pkg
2+
3+
import "testing"
4+
5+
func TestFoo(t *testing.T) {
6+
if fn1() == true {
7+
}
8+
}

0 commit comments

Comments
 (0)