Migrate golangci-lint from v1 to v2#3261
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdate linting toolchain to golangci-lint v2: migrate config schema, adjust Makefile targets to v2 command path, update tooling blank imports, and bump tooling dependencies in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.4)Command failed Comment |
Review Summary by QodoMigrate golangci-lint from v1 to v2
WalkthroughsDescription• Migrate golangci-lint from v1 (1.64.8) to v2 (2.11.4) • Move gci and goimports to formatters section in config • Exclude new v2-only checks to maintain parity with v1 • Update module paths and remove deprecated --sort-results flag Diagramflowchart LR
A["golangci-lint v1.64.8"] -- "upgrade version" --> B["golangci-lint v2.11.4"]
C[".golangci.yaml v1 config"] -- "restructure formatters" --> D[".golangci.yaml v2 config"]
E["tools/go.mod v1 path"] -- "update module path" --> F["tools/go.mod v2 path"]
G["Makefile v1 invocations"] -- "update go run paths" --> H["Makefile v2 invocations"]
B --> D
B --> F
B --> H
File Changes1. .golangci.yaml
|
Code Review by Qodo
1. No local lint timeout
|
| @go run -modfile tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run $(if $(GITHUB_ACTIONS), --timeout=10m0s) | ||
| @(cd acceptance && go run -modfile ../tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --path-prefix acceptance $(if $(GITHUB_ACTIONS), --timeout=10m0s)) |
There was a problem hiding this comment.
1. No local lint timeout 🐞 Bug ☼ Reliability
make lint only applies --timeout when GITHUB_ACTIONS is set, so local runs (and any non-GitHub CI) can run indefinitely under golangci-lint v2. This can hang developer workflows when analysis stalls or is unusually slow.
Agent Prompt
## Issue description
`make lint` (and the acceptance subdir lint) only sets `--timeout` when `GITHUB_ACTIONS` is present. With golangci-lint v2 having no default timeout, local/non-GHA runs can hang indefinitely.
## Issue Context
This is a workflow reliability regression after moving to golangci-lint v2.
## Fix Focus Areas
- Update `Makefile` to always pass a timeout (optionally configurable via a make var, e.g. `LINT_TIMEOUT ?= 10m0s`), and use it in both the root and `acceptance/` golangci-lint invocations.
### Fix locations
- Makefile[194-207]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
- Add `version: "2"` to `.golangci.yaml` - Move `gci` and `goimports` from `linters.enable` to `formatters.enable` with settings under `formatters.settings` - Add `linters.exclusions.presets` to preserve v1 default exclusion behavior - Exclude new v2-only gosec rules (G122, G702, G703) and staticcheck checks (QF*, ST*) that weren't active in v1 - Update `tools/go.mod` and `tools/tools.go` to the v2 module path - Update Makefile `go run` invocations to use v2 module path - Remove `--sort-results` flag (removed in v2, now default behavior) - Add `issues.exclude-generated: lax` to preserve v1 default Ref: EC-1756 Signed-off-by: Rob Nester <rnester@redhat.com> Made-with: Cursor
- Add staticcheck explicitly to linters.enable for clarity - Remove redundant gci write invocation from lint-fix target; golangci-lint v2 run --fix handles formatters including gci Ref: EC-1756 Signed-off-by: Rob Nester <rnester@redhat.com> Made-with: Cursor
Summary
Migrates golangci-lint from v1 (1.64.8) to v2 (2.11.4), resolving the CodeRabbit config parsing warning seen on recent PRs.
What changed:
.golangci.yaml: Addedversion: "2", movedgci/goimportstoformatterssection, added v1-equivalent exclusion presets, excluded new v2-only checks (gosec G122/G702/G703, staticcheck QF*/ST*) to maintain paritytools/go.mod+tools/tools.go: Updated module path fromgithub.com/golangci/golangci-lint→github.com/golangci/golangci-lint/v2Makefile: Updatedgo runpaths to v2, removed--sort-resultsflag (now default in v2)Acceptance Criteria
version: "2"is present in.golangci.yamlgciandgoimportsare underformatters.enable, notlinters.enabletools/go.modreferencesgithub.com/golangci/golangci-lint/v2go runpaths use the v2 module pathmake lintpasses locallymake lint-fixstill auto-fixes formatting issuesNotes
staticchecklinter now bundles ST* (style) and QF* (quickfix) checks that were previously in the separatestylechecklinter (not enabled in our v1 config). These are excluded to maintain parity — enabling them can be done in a follow-up.tools/go.modandtools/go.sumdiff is mechanical dependency resolution — sanity check, not line-by-line.Ref: EC-1756
Made with Cursor