fix(lint): resolve all 49 golangci-lint issues#262
Merged
Conversation
- Upgrade golangci-lint config to v2 with stricter linters
- Replace interface{} with any and use maps.Copy, strings.SplitSeq
- Use errors.New for static error strings instead of fmt.Errorf
- Use http.StatusOK and http.MethodGet stdlib constants in tests
- Replace os.Chdir/os.Setenv with t.Chdir/t.Setenv in tests
- Add required explanations to all nolint directives
- Replace fmt.Printf with proper error returns in anthropic provider
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the repository’s linting configuration to golangci-lint v2 with a stricter linter set, and applies code/test changes across the codebase to resolve the reported lint violations.
Changes:
- Upgraded
.golangci.ymlto v2 and enabled additional linters with new settings/exclusions. - Modernized Go code to satisfy lint rules (e.g.,
any,maps.Copy,strings.SplitSeq,errors.New, stdlib constants). - Improved test hygiene by using
t.Setenv/t.Chdirand addingnolintexplanations where required.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| version/version.go | Simplifies App var declaration to satisfy style/lint. |
| util/util_test.go | Switches test setup to use t.Setenv and removes error-returning setup. |
| util/template_test.go | Uses any + maps.Copy to populate template vars. |
| util/template.go | Updates template data types and function signatures to any. |
| util/api_key_helper_unix.go | Replaces static fmt.Errorf with errors.New for constant errors. |
| util/api_key_helper_test.go | Uses t.Setenv and adjusts command construction in cache-expiration test. |
| util/api_key_helper.go | Adds nilnil explanations and uses errors.New for static errors. |
| proxy/proxy.go | Uses errors.New for static errors and improves nolint:gosec rationale formatting. |
| provider/openai/openai.go | Uses errors.New for static “no choices” error. |
| provider/anthropic/anthropic.go | Removes fmt.Printf and returns formatted errors instead. |
| prompt/prompt.go | Adds explanation to nolint:gochecknoinits. |
| git/hook.go | Adds explanation to nolint:gochecknoinits. |
| git/git_test.go | Uses t.Chdir and simplifies error variable usage. |
| git/git.go | Replaces fmt.Sprintf with concatenation and adds nolint:gosec explanation. |
| core/transport/transport_test.go | Uses stdlib constants (http.StatusOK, http.MethodGet) and formats request creation. |
| cmd/version.go | Changes output printing to use color.White. |
| cmd/textarea.go | Uses strings.SplitSeq and adds explanation to nolint:exhaustive. |
| cmd/commit.go | Uses maps.Copy when merging template vars into util.Data. |
| .golangci.yml | Migrates to golangci-lint v2 config and enables/configures additional linters/formatters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Wrap original error with %w in anthropic APIError branches - Add trailing newline to color.White version output - Quote file path in test shell command with fmt.Sprintf %q Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use errors.New for static error strings in api_key_helper_windows.go - Modernize for loops to range over int in windows test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
.golangci.ymlto v2 with stricter linters (modernize, perfsprint, usestdlibvars, usetesting, nilnil, forbidigo, depguard, revive)interface{}withany, usemaps.Copy/strings.SplitSeq, useerrors.Newfor static errors, use stdlib constants, uset.Chdir/t.Setenvin tests, add nolint explanations, replacefmt.Printfwith proper error returnsTest plan
make lintpasses with 0 issuesmake testpasses with all tests green🤖 Generated with Claude Code