Skip to content

Commit

Permalink
build(deps): bump github.com/Antonboom/testifylint from 1.1.3 to 1.2.0 (
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom authored Mar 3, 2024
1 parent 9b560aa commit 61f2f70
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,10 @@ linters-settings:
- suite-thelper
- useless-assert

bool-compare:
# To ignore user defined types (over builtin bool).
# Default: false
ignore-custom-types: true
expected-actual:
# Regexp for expected variable name.
# Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/Abirdcfly/dupword v0.0.14
github.com/Antonboom/errname v0.1.12
github.com/Antonboom/nilnil v0.1.7
github.com/Antonboom/testifylint v1.1.3
github.com/Antonboom/testifylint v1.2.0
github.com/BurntSushi/toml v1.3.2
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ type TestifylintSettings struct {
EnabledCheckers []string `mapstructure:"enable"`
DisabledCheckers []string `mapstructure:"disable"`

BoolCompare struct {
IgnoreCustomTypes bool `mapstructure:"ignore-custom-types"`
} `mapstructure:"bool-compare"`

ExpectedActual struct {
ExpVarPattern string `mapstructure:"pattern"`
} `mapstructure:"expected-actual"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/golinters/testifylint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func NewTestifylint(settings *config.TestifylintSettings) *goanalysis.Linter {
cfg[a.Name] = map[string]any{
"enable-all": settings.EnableAll,
"disable-all": settings.DisableAll,

"bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes,
}
if len(settings.EnabledCheckers) > 0 {
cfg[a.Name]["enable"] = settings.EnabledCheckers
Expand Down
6 changes: 6 additions & 0 deletions test/testdata/configs/testifylint_bool_compare_only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters-settings:
testifylint:
disable-all: true
enable: bool-compare
bool-compare:
ignore-custom-types: true
File renamed without changes.
3 changes: 3 additions & 0 deletions test/testdata/testifylint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/stretchr/testify/suite"
)

type Bool bool

func TestTestifylint(t *testing.T) {
var (
predicate bool
Expand All @@ -20,6 +22,7 @@ func TestTestifylint(t *testing.T) {
)

assert.Equal(t, predicate, true) // want "bool-compare: use assert\\.True"
assert.Equal(t, Bool(predicate), false) // want "bool-compare: use assert\\.False"
assert.True(t, resultInt == 1) // want "compares: use assert\\.Equal"
assert.Equal(t, len(arr), 0) // want "empty: use assert\\.Empty"
assert.Error(t, err, io.EOF) // want "error-is-as: invalid usage of assert\\.Error, use assert\\.ErrorIs instead"
Expand Down
17 changes: 17 additions & 0 deletions test/testdata/testifylint_bool_compare.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//golangcitest:args -Etestifylint
//golangcitest:config_path testdata/configs/testifylint_bool_compare_only.yml
package testdata

import (
"testing"

"github.com/stretchr/testify/assert"
)

type Bool bool

func TestTestifylint(t *testing.T) {
var predicate bool
assert.Equal(t, predicate, true) // want "bool-compare: use assert\\.True"
assert.Equal(t, Bool(predicate), false)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Etestifylint
//golangcitest:config_path testdata/configs/testifylint.yml
//golangcitest:config_path testdata/configs/testifylint_require_error_only.yml
package testdata

import (
Expand Down

0 comments on commit 61f2f70

Please sign in to comment.