ci: enable govet for test files in golangci-lint - #2784
Closed
t-kikuc wants to merge 1 commit into
Closed
Conversation
Remove `run.tests: false` and replace with per-linter exclusion rules so that govet runs on test files while other linters remain excluded. Fix sync.Map value copy violation detected by copylocks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Enables govet checks for Go test files while suppressing noisier linters.
Changes:
- Replaces the global test exclusion with per-linter exclusions.
- Refactors cache tests to avoid copying
sync.Map.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.golangci.yml |
Enables govet for tests while excluding other linters. |
pkg/api/api/save_api_key_last_used_at_test.go |
Avoids sync.Map value copies in test cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Remove
run.tests: falsefrom.golangci.ymland replace with per-linter exclusion rules, so thatgovetruns on test files while other linters remain excluded. Fix existingsync.Mapvalue copy violation detected by thecopylocksanalyzer.Background
.golangci.ymlhadrun.tests: false, which excluded all test files from all linters includinggovet.govethas very low false-positive rates and catches real bugs — thecopylocksanalyzer, for example, has existed since at least Go 1.21 but its violations in test files were invisible in CI.Other linters (
errcheck,goheader,lll, etc.) can be noisy on test files, so enablingtests: trueglobally is not ideal. golangci-lint v2 supports per-linter exclusion vialinters.exclusions.rules, which allows enablinggovetfor tests while keeping other linters excluded.Verification commands
Points
copylocksissue insave_api_key_last_used_at_test.gopredates this PR — it was never detected because test files were excluded from lintingexistingCache sync.Map/expectedCache sync.Mapare replaced withsetupCache func(*sync.Map)/expectedCache map[string]apikeyLastUsedAtto avoid value copies ofsync.Map