From 73110df2cef7c8db91e2703d5b05d41512cf2276 Mon Sep 17 00:00:00 2001 From: Anton Telyshev Date: Sun, 19 May 2024 21:37:03 +0300 Subject: [PATCH] build(deps): bump github.com/Antonboom/testifylint from 1.2.0 to 1.3.0 (#4729) --- .golangci.next.reference.yml | 12 +++- go.mod | 2 +- go.sum | 4 +- jsonschema/golangci.next.jsonschema.json | 74 ++++++++++++++++++------ pkg/config/linters_settings.go | 4 ++ pkg/goanalysis/linter.go | 2 +- pkg/golinters/testifylint/testifylint.go | 1 + 7 files changed, 74 insertions(+), 25 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index da278de696cc..11a76febf47f 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2176,9 +2176,10 @@ linters-settings: - error-is-as - error-nil - expected-actual - - go-require - float-compare + - go-require - len + - negative-positive - nil-compare - require-error - suite-dont-use-pkg @@ -2192,7 +2193,7 @@ linters-settings: # Enable checkers by name # (in addition to default # blank-import, bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare, - # len, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert + # len, negative-positive, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert # ). enable: - blank-import @@ -2202,9 +2203,10 @@ linters-settings: - error-is-as - error-nil - expected-actual - - go-require - float-compare + - go-require - len + - negative-positive - nil-compare - require-error - suite-dont-use-pkg @@ -2220,6 +2222,10 @@ linters-settings: # Regexp for expected variable name. # Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$) pattern: ^expected + go-require: + # To ignore HTTP handlers (like http.HandlerFunc). + # Default: false + ignore-http-handlers: true require-error: # Regexp for assertions to analyze. If defined, then only matched error assertions will be reported. # Default: "" diff --git a/go.mod b/go.mod index 52524fe7755e..91249f5ef713 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/Abirdcfly/dupword v0.0.14 github.com/Antonboom/errname v0.1.13 github.com/Antonboom/nilnil v0.1.9 - github.com/Antonboom/testifylint v1.2.0 + github.com/Antonboom/testifylint v1.3.0 github.com/BurntSushi/toml v1.3.2 github.com/Crocmagnon/fatcontext v0.2.2 github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 diff --git a/go.sum b/go.sum index 52b613e66e39..db81fb81d76c 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHO github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns= github.com/Antonboom/nilnil v0.1.9 h1:eKFMejSxPSA9eLSensFmjW2XTgTwJMjZ8hUHtV4s/SQ= github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ= -github.com/Antonboom/testifylint v1.2.0 h1:015bxD8zc5iY8QwTp4+RG9I4kIbqwvGX9TrBbb7jGdM= -github.com/Antonboom/testifylint v1.2.0/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw= +github.com/Antonboom/testifylint v1.3.0 h1:UiqrddKs1W3YK8R0TUuWwrVKlVAnS07DTUVWWs9c+y4= +github.com/Antonboom/testifylint v1.3.0/go.mod h1:NV0hTlteCkViPW9mSR4wEMfwp+Hs1T3dY60bkvSfhpM= 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= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 77edb3359731..abaa7edc8155 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -2779,16 +2779,6 @@ "type": "object", "additionalProperties": false, "properties": { - "bool-compare": { - "type": "object", - "additionalProperties": false, - "properties": { - "ignore-custom-types": { - "type": "boolean", - "default": false - } - } - }, "enable-all": { "description": "Enable all checkers.", "type": "boolean", @@ -2811,9 +2801,10 @@ "error-is-as", "error-nil", "expected-actual", - "go-require", "float-compare", + "go-require", "len", + "negative-positive", "nil-compare", "require-error", "suite-dont-use-pkg", @@ -2821,10 +2812,28 @@ "suite-thelper", "useless-assert" ] - } + }, + "default": [ + "blank-import", + "bool-compare", + "compares", + "empty", + "error-is-as", + "error-nil", + "expected-actual", + "float-compare", + "go-require", + "len", + "negative-positive", + "nil-compare", + "require-error", + "suite-dont-use-pkg", + "suite-extra-assert-call", + "useless-assert" + ] }, "disable": { - "description": "Enable specific checkers.", + "description": "Disable specific checkers.", "type": "array", "items": { "enum": [ @@ -2835,25 +2844,52 @@ "error-is-as", "error-nil", "expected-actual", - "go-require", "float-compare", + "go-require", "len", + "negative-positive", "nil-compare", "require-error", "suite-dont-use-pkg", "suite-extra-assert-call", "suite-thelper", "useless-assert" + ], + "default": [ + "suite-thelper" ] } }, + "bool-compare": { + "type": "object", + "additionalProperties": false, + "properties": { + "ignore-custom-types": { + "description": "To ignore user defined types (over builtin bool).", + "type": "boolean", + "default": false + } + } + }, "expected-actual": { "type": "object", "additionalProperties": false, "properties": { "pattern": { "description": "Regexp for expected variable name.", - "type": "string" + "type": "string", + "default": "(^(exp(ected)?|want(ed)?)([A-Z]\\w*)?$)|(^(\\w*[a-z])?(Exp(ected)?|Want(ed)?)$)" + } + } + }, + "go-require": { + "type": "object", + "additionalProperties": false, + "properties": { + "ignore-http-handlers": { + "description": "To ignore HTTP handlers (like http.HandlerFunc).", + "type": "boolean", + "default": false } } }, @@ -2862,8 +2898,9 @@ "additionalProperties": false, "properties": { "fn-pattern": { - "description": "Regexp for expected variable name.", - "type": "string" + "description": "Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.", + "type": "string", + "default": "" } } }, @@ -2874,7 +2911,8 @@ "mode": { "description": "To require or remove extra Assert() call?", "type": "string", - "enum": ["remove", "require"] + "enum": ["remove", "require"], + "default": "remove" } } } diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 876b40cfbf83..0ebec511750c 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -882,6 +882,10 @@ type TestifylintSettings struct { ExpVarPattern string `mapstructure:"pattern"` } `mapstructure:"expected-actual"` + GoRequire struct { + IgnoreHTTPHandlers bool `mapstructure:"ignore-http-handlers"` + } `mapstructure:"go-require"` + RequireError struct { FnPattern string `mapstructure:"fn-pattern"` } `mapstructure:"require-error"` diff --git a/pkg/goanalysis/linter.go b/pkg/goanalysis/linter.go index 33f2254b02b1..13d3a09a585a 100644 --- a/pkg/goanalysis/linter.go +++ b/pkg/goanalysis/linter.go @@ -116,7 +116,7 @@ func (*Linter) configureAnalyzer(a *analysis.Analyzer, cfg map[string]any) error } if err := f.Value.Set(valueToString(v)); err != nil { - return fmt.Errorf("failed to set analyzer setting %q with value %v: %w", k, v, err) + return fmt.Errorf("failed to set analyzer setting %q with value %q: %w", k, v, err) } } diff --git a/pkg/golinters/testifylint/testifylint.go b/pkg/golinters/testifylint/testifylint.go index 55c96881d83b..a5f95a1e83a4 100644 --- a/pkg/golinters/testifylint/testifylint.go +++ b/pkg/golinters/testifylint/testifylint.go @@ -18,6 +18,7 @@ func New(settings *config.TestifylintSettings) *goanalysis.Linter { "disable-all": settings.DisableAll, "bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes, + "go-require.ignore-http-handlers": settings.GoRequire.IgnoreHTTPHandlers, } if len(settings.EnabledCheckers) > 0 { cfg[a.Name]["enable"] = settings.EnabledCheckers