Skip to content

Commit 64c6528

Browse files
dependabot[bot]ldezAntonboom
authoredMar 13, 2025··
build(deps): bump github.com/Antonboom/testifylint from 1.5.2 to 1.6.0 (#5542)
Co-authored-by: Fernandez Ludovic <[email protected]> Co-authored-by: Anton Telyshev <[email protected]>
1 parent 07e4a33 commit 64c6528

16 files changed

+81
-10
lines changed
 

‎.golangci.next.reference.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,7 @@ linters:
33993399
- contains
34003400
- empty
34013401
- encoded-compare
3402+
- equal-values
34023403
- error-is-as
34033404
- error-nil
34043405
- expected-actual
@@ -3413,6 +3414,7 @@ linters:
34133414
- suite-broken-parallel
34143415
- suite-dont-use-pkg
34153416
- suite-extra-assert-call
3417+
- suite-method-signature
34163418
- suite-subtest-run
34173419
- suite-thelper
34183420
- useless-assert
@@ -3422,9 +3424,10 @@ linters:
34223424
disable-all: true
34233425
# Enable checkers by name
34243426
# (in addition to default
3425-
# blank-import, bool-compare, compares, contains, empty, encoded-compare, error-is-as, error-nil, expected-actual,
3426-
# go-require, float-compare, formatter, len, negative-positive, nil-compare, regexp, require-error,
3427-
# suite-broken-parallel, suite-dont-use-pkg, suite-extra-assert-call, suite-subtest-run, useless-assert
3427+
# blank-import, bool-compare, compares, contains, empty, encoded-compare, equal-values, error-is-as, error-nil,
3428+
# expected-actual, go-require, float-compare, formatter, len, negative-positive, nil-compare, regexp, require-error,
3429+
# suite-broken-parallel, suite-dont-use-pkg, suite-extra-assert-call, suite-subtest-run, suite-method-signature,
3430+
# useless-assert
34283431
# ).
34293432
enable:
34303433
- blank-import
@@ -3433,6 +3436,7 @@ linters:
34333436
- contains
34343437
- empty
34353438
- encoded-compare
3439+
- equal-values
34363440
- error-is-as
34373441
- error-nil
34383442
- expected-actual
@@ -3447,6 +3451,7 @@ linters:
34473451
- suite-broken-parallel
34483452
- suite-dont-use-pkg
34493453
- suite-extra-assert-call
3454+
- suite-method-signature
34503455
- suite-subtest-run
34513456
- suite-thelper
34523457
- useless-assert
@@ -3471,6 +3476,10 @@ linters:
34713476
# https://github.com/Antonboom/testifylint?tab=readme-ov-file#historical-reference-of-formatter.
34723477
# Default: false
34733478
require-f-funcs: true
3479+
# To require that the first element of msgAndArgs (msg) has a string type.
3480+
# For example, in such case assertion like `assert.True(t, b, tt.case)` will be considered as invalid.
3481+
# Default: true
3482+
require-string-msg: false
34743483
go-require:
34753484
# To ignore HTTP handlers (like http.HandlerFunc).
34763485
# Default: false

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/Abirdcfly/dupword v0.1.3
1010
github.com/Antonboom/errname v1.1.0
1111
github.com/Antonboom/nilnil v1.0.1
12-
github.com/Antonboom/testifylint v1.5.2
12+
github.com/Antonboom/testifylint v1.6.0
1313
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
1414
github.com/Crocmagnon/fatcontext v0.7.1
1515
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24

‎go.sum

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

‎jsonschema/golangci.jsonschema.json

+11
Original file line numberDiff line numberDiff line change
@@ -3370,6 +3370,7 @@
33703370
"contains",
33713371
"empty",
33723372
"encoded-compare",
3373+
"equal-values",
33733374
"error-is-as",
33743375
"error-nil",
33753376
"expected-actual",
@@ -3384,6 +3385,7 @@
33843385
"suite-broken-parallel",
33853386
"suite-dont-use-pkg",
33863387
"suite-extra-assert-call",
3388+
"suite-method-signature",
33873389
"suite-subtest-run",
33883390
"suite-thelper",
33893391
"useless-assert"
@@ -3396,6 +3398,7 @@
33963398
"contains",
33973399
"empty",
33983400
"encoded-compare",
3401+
"equal-values",
33993402
"error-is-as",
34003403
"error-nil",
34013404
"expected-actual",
@@ -3410,6 +3413,7 @@
34103413
"suite-broken-parallel",
34113414
"suite-dont-use-pkg",
34123415
"suite-extra-assert-call",
3416+
"suite-method-signature",
34133417
"suite-subtest-run",
34143418
"useless-assert"
34153419
]
@@ -3425,6 +3429,7 @@
34253429
"contains",
34263430
"empty",
34273431
"encoded-compare",
3432+
"equal-values",
34283433
"error-is-as",
34293434
"error-nil",
34303435
"expected-actual",
@@ -3439,6 +3444,7 @@
34393444
"suite-broken-parallel",
34403445
"suite-dont-use-pkg",
34413446
"suite-extra-assert-call",
3447+
"suite-method-signature",
34423448
"suite-subtest-run",
34433449
"suite-thelper",
34443450
"useless-assert"
@@ -3483,6 +3489,11 @@
34833489
"description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
34843490
"type": "boolean",
34853491
"default": false
3492+
},
3493+
"require-string-msg": {
3494+
"description": "To require that the first element of msgAndArgs (msg) has a string type.",
3495+
"type": "boolean",
3496+
"default": true
34863497
}
34873498
}
34883499
},

‎jsonschema/golangci.next.jsonschema.json

+11
Original file line numberDiff line numberDiff line change
@@ -3370,6 +3370,7 @@
33703370
"contains",
33713371
"empty",
33723372
"encoded-compare",
3373+
"equal-values",
33733374
"error-is-as",
33743375
"error-nil",
33753376
"expected-actual",
@@ -3384,6 +3385,7 @@
33843385
"suite-broken-parallel",
33853386
"suite-dont-use-pkg",
33863387
"suite-extra-assert-call",
3388+
"suite-method-signature",
33873389
"suite-subtest-run",
33883390
"suite-thelper",
33893391
"useless-assert"
@@ -3396,6 +3398,7 @@
33963398
"contains",
33973399
"empty",
33983400
"encoded-compare",
3401+
"equal-values",
33993402
"error-is-as",
34003403
"error-nil",
34013404
"expected-actual",
@@ -3410,6 +3413,7 @@
34103413
"suite-broken-parallel",
34113414
"suite-dont-use-pkg",
34123415
"suite-extra-assert-call",
3416+
"suite-method-signature",
34133417
"suite-subtest-run",
34143418
"useless-assert"
34153419
]
@@ -3425,6 +3429,7 @@
34253429
"contains",
34263430
"empty",
34273431
"encoded-compare",
3432+
"equal-values",
34283433
"error-is-as",
34293434
"error-nil",
34303435
"expected-actual",
@@ -3439,6 +3444,7 @@
34393444
"suite-broken-parallel",
34403445
"suite-dont-use-pkg",
34413446
"suite-extra-assert-call",
3447+
"suite-method-signature",
34423448
"suite-subtest-run",
34433449
"suite-thelper",
34443450
"useless-assert"
@@ -3483,6 +3489,11 @@
34833489
"description": "To require f-assertions (e.g. assert.Equalf) if format string is used, even if there are no variable-length variables.",
34843490
"type": "boolean",
34853491
"default": false
3492+
},
3493+
"require-string-msg": {
3494+
"description": "To require that the first element of msgAndArgs (msg) has a string type.",
3495+
"type": "boolean",
3496+
"default": true
34863497
}
34873498
}
34883499
},

‎pkg/config/linters_settings.go

+2
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ type TestifylintSettings struct {
849849
Formatter TestifylintFormatter `mapstructure:"formatter"`
850850
GoRequire TestifylintGoRequire `mapstructure:"go-require"`
851851
RequireError TestifylintRequireError `mapstructure:"require-error"`
852+
RequireStringMsg bool `mapstructure:"require-string-msg"`
852853
SuiteExtraAssertCall TestifylintSuiteExtraAssertCall `mapstructure:"suite-extra-assert-call"`
853854
}
854855

@@ -863,6 +864,7 @@ type TestifylintExpectedActual struct {
863864
type TestifylintFormatter struct {
864865
CheckFormatString *bool `mapstructure:"check-format-string"`
865866
RequireFFuncs bool `mapstructure:"require-f-funcs"`
867+
RequireStringMsg bool `mapstructure:"require-string-msg"`
866868
}
867869

868870
type TestifylintGoRequire struct {

‎pkg/golinters/testifylint/testdata/fix/in/testifylint.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func TestTestifylint(t *testing.T) {
3030
assert.Nil(t, err) // want "error-nil: use assert\\.NoError"
3131
assert.Equal(t, resultInt, 42) // want "expected-actual: need to reverse actual and expected values"
3232
assert.Equal(t, resultFloat, 42.42) // want "float-compare: use assert\\.InEpsilon \\(or InDelta\\)"
33-
assert.Equal(t, len(arr), 10) // want "len: use assert\\.Len"
33+
assert.Equal(t, len(arr), 10) // want "expected-actual: need to reverse actual and expected values"
34+
assert.Equal(t, 10, len(arr)) // want "len: use assert\\.Len"
3435

3536
assert.True(t, predicate)
3637
assert.Equal(t, resultInt, 1) // want "expected-actual: need to reverse actual and expected values"

‎pkg/golinters/testifylint/testdata/fix/out/testifylint.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestTestifylint(t *testing.T) {
3030
assert.NoError(t, err) // want "error-nil: use assert\\.NoError"
3131
assert.Equal(t, 42, resultInt) // want "expected-actual: need to reverse actual and expected values"
3232
assert.Equal(t, resultFloat, 42.42) // want "float-compare: use assert\\.InEpsilon \\(or InDelta\\)"
33+
assert.Equal(t, 10, len(arr)) // want "expected-actual: need to reverse actual and expected values"
3334
assert.Len(t, arr, 10) // want "len: use assert\\.Len"
3435

3536
assert.True(t, predicate)

‎pkg/golinters/testifylint/testdata/testifylint.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func TestTestifylint(t *testing.T) {
3030
assert.Nil(t, err) // want "error-nil: use assert\\.NoError"
3131
assert.Equal(t, resultInt, 42) // want "expected-actual: need to reverse actual and expected values"
3232
assert.Equal(t, resultFloat, 42.42) // want "float-compare: use assert\\.InEpsilon \\(or InDelta\\)"
33-
assert.Equal(t, len(arr), 10) // want "len: use assert\\.Len"
33+
assert.Equal(t, len(arr), 10) // want "expected-actual: need to reverse actual and expected values"
34+
assert.Equal(t, 10, len(arr)) // want "len: use assert\\.Len"
3435

3536
assert.True(t, predicate)
3637
assert.Equal(t, resultInt, 1) // want "expected-actual: need to reverse actual and expected values"

‎pkg/golinters/testifylint/testdata/testifylint_cgo.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ func TestTestifylint(t *testing.T) {
4646
assert.Nil(t, err) // want "error-nil: use assert\\.NoError"
4747
assert.Equal(t, resultInt, 42) // want "expected-actual: need to reverse actual and expected values"
4848
assert.Equal(t, resultFloat, 42.42) // want "float-compare: use assert\\.InEpsilon \\(or InDelta\\)"
49-
assert.Equal(t, len(arr), 10) // want "len: use assert\\.Len"
49+
assert.Equal(t, len(arr), 10) // want "expected-actual: need to reverse actual and expected values"
50+
assert.Equal(t, 10, len(arr)) // want "len: use assert\\.Len"
5051

5152
assert.True(t, predicate)
5253
assert.Equal(t, resultInt, 1) // want "expected-actual: need to reverse actual and expected values"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//golangcitest:args -Etestifylint
2+
//golangcitest:config_path testdata/testifylint_formatter_dont_require_string_msg.yml
3+
package testdata
4+
5+
import (
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestTestifylint(t *testing.T) {
12+
var b bool
13+
assert.True(t, b, b)
14+
assert.True(t, b, "msg %v", 1)
15+
assert.True(t, b, b, 1) // want "formatter: using msgAndArgs with non-string first element \\(msg\\) causes panic"
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
testifylint:
6+
disable-all: true
7+
enable:
8+
- formatter
9+
formatter:
10+
check-format-string: false
11+
require-f-funcs: false
12+
require-string-msg: false

‎pkg/golinters/testifylint/testdata/testifylint_formatter_only.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import (
1212
func TestTestifylint(t *testing.T) {
1313
var err error
1414
var args []any
15+
var b bool
1516
assert.Error(t, err, "Parse(%v) should fail.", args) // want "formatter: use assert\\.Errorf$"
1617

1718
assert.Equal(t, 1, 2, fmt.Sprintf("msg")) // want "formatter: remove unnecessary fmt\\.Sprintf and use assert\\.Equalf"
1819
assert.DirExistsf(t, "", "msg with arg", 42)
20+
21+
assert.True(t, b, b) // want "formatter: do not use non-string value as first element \\(msg\\) of msgAndArgs"
22+
assert.True(t, b, b, 1) // want "formatter: using msgAndArgs with non-string first element \\(msg\\) causes panic"
1923
}

‎pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ linters:
99
formatter:
1010
check-format-string: false
1111
require-f-funcs: true
12+
require-string-msg: true

‎pkg/golinters/testifylint/testifylint.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func New(settings *config.TestifylintSettings) *goanalysis.Linter {
1919

2020
"bool-compare.ignore-custom-types": settings.BoolCompare.IgnoreCustomTypes,
2121
"formatter.require-f-funcs": settings.Formatter.RequireFFuncs,
22+
"formatter.require-string-msg": settings.Formatter.RequireStringMsg,
2223
"go-require.ignore-http-handlers": settings.GoRequire.IgnoreHTTPHandlers,
2324
}
2425
if len(settings.EnabledCheckers) > 0 {

‎test/testshared/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ type RunnerResult struct {
279279
func (r *RunnerResult) ExpectNoIssues() {
280280
r.tb.Helper()
281281

282-
assert.Equal(r.tb, "", r.output, "exit code is %d", r.exitCode)
282+
assert.Empty(r.tb, r.output, "exit code is %d", r.exitCode)
283283
assert.Equal(r.tb, exitcodes.Success, r.exitCode, "output is %s", r.output)
284284
}
285285

0 commit comments

Comments
 (0)
Please sign in to comment.