Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump github.com/Antonboom/testifylint from 1.1.3 to 1.2.0 #4449

Merged
merged 1 commit into from Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.reference.yml
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
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
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
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
@@ -0,0 +1,6 @@
linters-settings:
testifylint:
disable-all: true
enable: bool-compare
bool-compare:
ignore-custom-types: true
3 changes: 3 additions & 0 deletions test/testdata/testifylint.go
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
@@ -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)
}
@@ -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