Skip to content

testifylint: check to recommend Equal rather EqualValues fails early #5985

@fredbi

Description

@fredbi

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

How did you install golangci-lint?

Official GitHub Action

Description of the problem

When runnning testify lint, reported violations of the rule that recommends to use assert.Equal instead of assert.EqualValues (because both actual and expected are of the same type) fails early,
that is, it reports a few errors then bails.

This gives a terrible relinting experience, as I have to run golangci-lint run many times, fix a few issues, and repeat until all testifylint issues are exhausted.

Version of golangci-lint

Same behavior is observer when running a local build of golangci-lint

$ golangci-lint --version

2.3.1

Configuration

version: "2"
linters:
  default: all
  disable:
    - cyclop
    - depguard
    - errchkjson
    - errorlint
    - exhaustruct
    - forcetypeassert
    - funlen
    - gochecknoglobals
    - gochecknoinits
    - gocognit
    - godot
    - godox
    - gosmopolitan
    - inamedparam
    - ireturn
    - lll
    - musttag
    - nestif
    - nlreturn
    - noinlineerr
    - nonamedreturns
    - paralleltest
    - testpackage
    - thelper
    - tparallel
    - unparam
    - varnamelen
    - whitespace
    - wrapcheck
    - wsl
    - wsl_v5
  settings:
    dupl:
      threshold: 200
    goconst:
      min-len: 2
      min-occurrences: 3
    gocyclo:
      min-complexity: 45
  exclusions:
    generated: lax
    presets:
      - comments
      - common-false-positives
      - legacy
      - std-error-handling
    paths:
      - third_party$
      - builtin$
      - examples$
formatters:
  enable:
    - gofmt
    - goimports
  exclusions:
    generated: lax
    paths:
      - third_party$
      - builtin$
      - examples$

Go environment

$ go version && go env

go version go1.24.5 linux/amd64
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/fred/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/fred/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2440089954=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/fred/src/github.com/go-openapi/analysis/go.mod'
GOMODCACHE='/home/fred/pkg/mod'
GONOPROXY='github.com/oneconcern'
GONOSUMDB='github.com/oneconcern'
GOOS='linux'
GOPATH='/home/fred'
GOPRIVATE='github.com/oneconcern'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go-1.24'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/fred/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go-1.24/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.5'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
...
client/request_test.go:57:2: equal-values: use assert.Equal (testifylint)
	assert.EqualValues(t, []string{"json", "xml", "yaml"}, r.header["X-Accepts"])
	^
client/request_test.go:716:4: equal-values: use require.Equal (testifylint)
			require.EqualValues(t, "\"test body\"\n", string(bodyContent))
			^
client/request_test.go:724:4: equal-values: use require.Equal (testifylint)
			require.EqualValues(t, "\"test body\"\n", string(bodyContent))
			^
client/request_test.go:755:2: equal-values: use require.Equal (testifylint)
	require.EqualValues(t, "test result", actual)
	^
client/response_test.go:37:2: equal-values: use assert.Equal (testifylint)
	assert.EqualValues(t, under.StatusCode, resp.Code())
	^
client/runtime_test.go:133:2: equal-values: use assert.Equal (testifylint)
	assert.EqualValues(t, result, actual)

...

A minimal reproducible example or link to a public repository

Example above from github.com/go-openapi/runtime

// add your code here

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions