-
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugSomething isn't workingSomething isn't workingdependenciesRelates to an upstream dependencyRelates to an upstream dependency
Description
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
typechecksection 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?
Brew
Description of the problem
We're experiencing an issue where golangci-lint reports findings from external module files (located in the Go module cache), causing integration with SonarQube to fail. Specifically, the staticcheck linter is reporting issues in files not belonging to our repository, such as:
../go/pkg/mod/github.com/itchyny/gojq@v0.12.14/query.goThis leads to errors in SonarQube since the referenced file paths do not exist in the repository.
While we'll raise an issue directly with staticcheck, it seems like a good idea for golangci-lint itself to safeguard against linters reporting issues in files outside the repository.
Version of golangci-lint
❯ golangci-lint --version golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d on 2025-04-15T13:16:26ZConfiguration
golangci-lint run --verbose --timeout 30m --output.checkstyle.path=golangci-checkstyle.xml --output.text.path=stdout ./...version: "2" run: modules-download-mode: readonly linters: enable: - staticcheckGo environment
$ go version && go env # paste output hereVerbose output of running
~/staticcheck-repro ❯ golangci-lint cache clean ~/staticcheck-repro ❯ golangci-lint run -v INFO golangci-lint has version 2.1.2 built with go1.24.2 from 00a561d on 2025-04-15T13:16:26Z INFO [config_reader] Config search paths: [./ /Users/rcurrah/staticcheck-repro /Users/rcurrah /Users /] INFO [config_reader] Used config file .golangci.yml INFO maxprocs: Leaving GOMAXPROCS=14: CPU quota undefined INFO [goenv] Read go env for 11.152584ms: map[string]string{"GOCACHE":"/Users/rcurrah/Library/Caches/go-build", "GOROOT":"/Users/rcurrah/.go/current"} INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused] INFO [loader] Go packages loading at mode 8767 (compiled_files|exports_file|imports|deps|files|name|types_sizes) took 237.147875ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 136.417µs INFO [linters_context/goanalysis] analyzers took 898.344168ms with top 10 stages: buildir: 622.697337ms, ctrlflow: 37.093372ms, SA5012: 36.582161ms, fact_deprecated: 35.113296ms, printf: 35.059955ms, fact_purity: 34.720544ms, nilness: 33.435045ms, typedness: 31.178ms, inspect: 27.291206ms, tokenfileanalyzer: 1.743328ms INFO [runner] Issues before processing: 3, after processing: 2 INFO [runner] Processors filtering stat (in/out): path_shortener: 2/2, path_prettifier: 2/2, path_absoluter: 3/3, max_same_issues: 2/2, sort_results: 2/2, max_per_file_from_linter: 2/2, invalid_issue: 3/3, path_relativity: 3/3, exclusion_paths: 3/3, generated_file_filter: 3/3, uniq_by_line: 3/2, severity-rules: 2/2, filename_unadjuster: 3/3, diff: 3/3, fixer: 3/3, max_from_linter: 2/2, cgo: 3/3, exclusion_rules: 3/3, nolint_filter: 3/3, source_code: 2/2 INFO [runner] processing took 602.582µs with stages: nolint_filter: 490.792µs, generated_file_filter: 51.584µs, source_code: 42.417µs, cgo: 7.792µs, path_relativity: 2.499µs, uniq_by_line: 1.584µs, invalid_issue: 1.041µs, max_same_issues: 1µs, sort_results: 1µs, path_shortener: 666ns, max_from_linter: 375ns, path_absoluter: 292ns, max_per_file_from_linter: 291ns, exclusion_rules: 291ns, filename_unadjuster: 250ns, fixer: 208ns, path_prettifier: 167ns, diff: 125ns, exclusion_paths: 125ns, severity-rules: 83ns INFO [runner] linters took 501.213459ms with stages: goanalysis_metalinter: 500.571584ms ../go/pkg/mod/github.com/itchyny/gojq@v0.12.14/query.go:24:17: SA4023(related information): (*github.com/itchyny/gojq.Query).Run never returns a nil interface value (staticcheck) func (e *Query) Run(v any) Iter { ^ main.go:16:31: SA4023: this comparison is always true (staticcheck) if iter := query.Run(input); iter != nil { ^ 2 issues: * staticcheck: 2 INFO File cache stats: 2 entries of total size 19.7KiB INFO Memory: 9 samples, avg is 147.2MB, max is 261.2MB INFO Execution took 749.978291msA minimal reproducible example or link to a public repository
See repository for repro.
git clone https://github.com/ryancurrah/staticcheck-repro cd staticcheck-repro golangci-lint run -vValidation
- Yes, I've included all information above (version, config, etc.).
Supporter
- I am a sponsor/backer through GitHub or OpenCollective
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdependenciesRelates to an upstream dependencyRelates to an upstream dependency