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

This commit is contained in:
Anton Telyshev 2024-03-03 18:54:23 +03:00 committed by GitHub
parent 9b560aa88c
commit 61f2f70d07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 40 additions and 4 deletions

View File

@ -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)?)$)

2
go.mod
View File

@ -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

4
go.sum generated
View File

@ -43,8 +43,8 @@ github.com/Antonboom/errname v0.1.12 h1:oh9ak2zUtsLp5oaEd/erjB4GPu9w19NyoIskZClD
github.com/Antonboom/errname v0.1.12/go.mod h1:bK7todrzvlaZoQagP1orKzWXv59X/x0W0Io2XT1Ssro=
github.com/Antonboom/nilnil v0.1.7 h1:ofgL+BA7vlA1K2wNQOsHzLJ2Pw5B5DpWRLdDAVvvTow=
github.com/Antonboom/nilnil v0.1.7/go.mod h1:TP+ScQWVEq0eSIxqU8CbdT5DFWoHp0MbP+KMUO1BKYQ=
github.com/Antonboom/testifylint v1.1.3 h1:JowZ7xlzJzZFRUXE4iqoAkENnMv4xRibAxzgy/vIfQw=
github.com/Antonboom/testifylint v1.1.3/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw=
github.com/Antonboom/testifylint v1.2.0 h1:015bxD8zc5iY8QwTp4+RG9I4kIbqwvGX9TrBbb7jGdM=
github.com/Antonboom/testifylint v1.2.0/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=

View File

@ -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"`

View File

@ -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

View File

@ -0,0 +1,6 @@
linters-settings:
testifylint:
disable-all: true
enable: bool-compare
bool-compare:
ignore-custom-types: true

View File

@ -10,6 +10,8 @@ import (
"github.com/stretchr/testify/suite"
)
type Bool bool
func TestTestifylint(t *testing.T) {
var (
predicate bool
@ -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"

View File

@ -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)
}

View File

@ -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 (