Skip to content

Commit 61f2f70

Browse files
authored
build(deps): bump github.com/Antonboom/testifylint from 1.1.3 to 1.2.0 (#4449)
1 parent 9b560aa commit 61f2f70

10 files changed

+40
-4
lines changed

.golangci.reference.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,10 @@ linters-settings:
21972197
- suite-thelper
21982198
- useless-assert
21992199

2200+
bool-compare:
2201+
# To ignore user defined types (over builtin bool).
2202+
# Default: false
2203+
ignore-custom-types: true
22002204
expected-actual:
22012205
# Regexp for expected variable name.
22022206
# Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/Abirdcfly/dupword v0.0.14
1010
github.com/Antonboom/errname v0.1.12
1111
github.com/Antonboom/nilnil v0.1.7
12-
github.com/Antonboom/testifylint v1.1.3
12+
github.com/Antonboom/testifylint v1.2.0
1313
github.com/BurntSushi/toml v1.3.2
1414
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24
1515
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/linters_settings.go

+4
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,10 @@ type TestifylintSettings struct {
862862
EnabledCheckers []string `mapstructure:"enable"`
863863
DisabledCheckers []string `mapstructure:"disable"`
864864

865+
BoolCompare struct {
866+
IgnoreCustomTypes bool `mapstructure:"ignore-custom-types"`
867+
} `mapstructure:"bool-compare"`
868+
865869
ExpectedActual struct {
866870
ExpVarPattern string `mapstructure:"pattern"`
867871
} `mapstructure:"expected-actual"`

pkg/golinters/testifylint.go

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ func NewTestifylint(settings *config.TestifylintSettings) *goanalysis.Linter {
1616
cfg[a.Name] = map[string]any{
1717
"enable-all": settings.EnableAll,
1818
"disable-all": settings.DisableAll,
19+
20+
"bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes,
1921
}
2022
if len(settings.EnabledCheckers) > 0 {
2123
cfg[a.Name]["enable"] = settings.EnabledCheckers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
linters-settings:
2+
testifylint:
3+
disable-all: true
4+
enable: bool-compare
5+
bool-compare:
6+
ignore-custom-types: true

test/testdata/testifylint.go

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/stretchr/testify/suite"
1111
)
1212

13+
type Bool bool
14+
1315
func TestTestifylint(t *testing.T) {
1416
var (
1517
predicate bool
@@ -20,6 +22,7 @@ func TestTestifylint(t *testing.T) {
2022
)
2123

2224
assert.Equal(t, predicate, true) // want "bool-compare: use assert\\.True"
25+
assert.Equal(t, Bool(predicate), false) // want "bool-compare: use assert\\.False"
2326
assert.True(t, resultInt == 1) // want "compares: use assert\\.Equal"
2427
assert.Equal(t, len(arr), 0) // want "empty: use assert\\.Empty"
2528
assert.Error(t, err, io.EOF) // want "error-is-as: invalid usage of assert\\.Error, use assert\\.ErrorIs instead"
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//golangcitest:args -Etestifylint
2+
//golangcitest:config_path testdata/configs/testifylint_bool_compare_only.yml
3+
package testdata
4+
5+
import (
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
type Bool bool
12+
13+
func TestTestifylint(t *testing.T) {
14+
var predicate bool
15+
assert.Equal(t, predicate, true) // want "bool-compare: use assert\\.True"
16+
assert.Equal(t, Bool(predicate), false)
17+
}

test/testdata/testifylint_config.go renamed to test/testdata/testifylint_require_error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Etestifylint
2-
//golangcitest:config_path testdata/configs/testifylint.yml
2+
//golangcitest:config_path testdata/configs/testifylint_require_error_only.yml
33
package testdata
44

55
import (

0 commit comments

Comments
 (0)