Skip to content

ginkgolinter: false positive with Eventually(func(g Gomega){}) #5398

@Luap99

Description

@Luap99

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

Description of the problem

After the update to v1.64.2 I See false positives from the ginkgolinter about something like this

Eventually(func(g Gomega) {
	...
}).WithTimeout(time.Second).Should(Succeed())

per ginkgo docs this is valid and looking at ginkgolinter upstream this should be allowed
https://github.com/nunnatsa/ginkgolinter?tab=readme-ov-file#prevent-wrong-actual-values-with-the-succeed-matcher-bug

Running ginkgolinter directly with ginkgolinter ./... does not produce this error so I think this is something with the golangci-lint integration here that is triggering the issue.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.64.2 built with go1.24.0 from 1dae906b on 2025-02-11T21:44:55Z

Configuration

$ golangci-lint run -E ginkgolinter

Go environment

$ go version && go env
go version go1.22.10 linux/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/pholzing/.cache/go-build'
GOENV='/home/pholzing/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/pholzing/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/pholzing/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.10'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/pholzing/CODE/test/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1629350348=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO golangci-lint has version 1.64.2 built with go1.24.0 from 1dae906b on 2025-02-11T21:44:55Z 
INFO [config_reader] Config search paths: [./ /home/pholzing/CODE/test /home/pholzing/CODE /home/pholzing /home /] 
INFO [goenv] Read go env for 1.797459ms: map[string]string{"GOCACHE":"/home/pholzing/.cache/go-build", "GOROOT":"/usr/lib/golang"} 
INFO [lintersdb] Active 7 linters: [errcheck ginkgolinter gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 8767 (types_sizes|deps|imports|name|compiled_files|exports_file|files) took 81.159661ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 157.205µs 
INFO [linters_context/goanalysis] analyzers took 10.89424182s with top 10 stages: buildir: 9.182147313s, inspect: 566.134956ms, printf: 246.549697ms, fact_deprecated: 210.963565ms, ctrlflow: 199.736962ms, fact_purity: 134.388019ms, SA5012: 120.647631ms, nilness: 113.740309ms, typedness: 84.086307ms, tokenfileanalyzer: 30.456012ms 
INFO [runner] Processors filtering stat (in/out): path_shortener: 1/1, nolint_filter: 1/1, filename_unadjuster: 1/1, path_relativity: 1/1, skip_files: 1/1, identifier_marker: 1/1, uniq_by_line: 1/1, max_from_linter: 1/1, source_code: 1/1, skip_dirs: 1/1, path_prettifier: 1/1, sort_results: 1/1, diff: 1/1, cgo: 1/1, exclusion_paths: 1/1, generated_file_filter: 1/1, exclusion_rules: 1/1, max_per_file_from_linter: 1/1, max_same_issues: 1/1, severity-rules: 1/1, path_absoluter: 1/1, invalid_issue: 1/1, fixer: 1/1 
INFO [runner] processing took 180.764µs with stages: nolint_filter: 85.037µs, exclusion_rules: 49.85µs, generated_file_filter: 17.652µs, source_code: 12.949µs, skip_dirs: 6.063µs, uniq_by_line: 1.241µs, path_relativity: 1.122µs, max_same_issues: 807ns, max_from_linter: 688ns, cgo: 687ns, path_shortener: 658ns, sort_results: 570ns, invalid_issue: 463ns, identifier_marker: 447ns, path_absoluter: 417ns, exclusion_paths: 387ns, filename_unadjuster: 378ns, fixer: 345ns, max_per_file_from_linter: 285ns, path_prettifier: 274ns, diff: 201ns, skip_files: 167ns, severity-rules: 76ns 
INFO [runner] linters took 2.527715867s with stages: goanalysis_metalinter: 2.527488805s 
main_test.go:19:3: ginkgo-linter: Success matcher only support a single error value, or function with Gomega as its first parameter (ginkgolinter)
		Eventually(func(g Gomega) {
		^
INFO File cache stats: 1 entries of total size 360B 
INFO Memory: 28 samples, avg is 669.4MB, max is 1159.0MB 
INFO Execution took 2.611434894s 

A minimal reproducible example or link to a public repository

package main_test

import (
	"testing"
	"time"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

func TestBooks(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "t")
}

var _ = Describe("t", func() {

	It("t", func() {
		Eventually(func(g Gomega) {
			g.Expect("abc").To(Equal("abc"))
		}).WithTimeout(time.Second).Should(Succeed())
	})

})

Validation

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

Supporter

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdependenciesRelates to an upstream dependency

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions