Upgrade golangci-lint to v2 and fix all lint issues#433
Open
Upgrade golangci-lint to v2 and fix all lint issues#433
Conversation
d34ae12 to
b2e737d
Compare
83cd419 to
a16bb19
Compare
Migrate .golangci.yml to the v2 config format required by golangci-lint 2.x. Replace enable-all with default:all, update disable list with current linter names, and add exclusion presets and formatters.
Mechanical replacement of interface{} with the any type alias
introduced in Go 1.18, followed by gofmt to fix alignment.
Use errors.New for static error strings and string concatenation instead of fmt.Sprintf for simple joins (perfsprint).
Remove unused struct fields and type definitions flagged by the unused linter.
UUID is a type alias so explicit conversions are redundant.
Convert traditional C-style for loops to Go 1.22+ integer range syntax.
Fix deprecated API usage (ioutil, rand.Seed), possible nil pointer dereferences in tests, duplicate imports, and simplify boolean/select expressions.
Rewrite single-case switches to if statements, convert if-else chains to switch statements, and fix exported parameter naming.
Handle previously ignored error returns across production and test code.
Go 1.22+ captures loop variables correctly, making the re-assignment pattern `name, tc := name, tc` unnecessary.
Convert C-style for loops to Go 1.22+ integer range syntax in kafka eventbus and command_check.
Replace fmt.Errorf with errors.New where no format verbs are used.
Omit unused receiver names instead of using underscore.
Define contextKey type for context.WithValue calls (SA1029) and fix unused variable assignment in acceptance tests.
Replace reflect.TypeOf with reflect.TypeFor, and map copy loops with maps.Copy.
Replace string literals with http.MethodGet and http.MethodPost.
Apply De Morgan law simplification, replace weak random generators, add nolint directives for acceptable gosec false positives, add ReadHeaderTimeout to http.Server, and remove unnecessary conversion.
Fix leading/trailing newline issues flagged by the whitespace linter.
Bump version in .tool-versions and fix newly detected intrange issue.
Use errors.Is() for sentinel error comparisons and %w for error wrapping in fmt.Errorf calls.
Remove unused function parameters across event bus, event store, and outbox implementations.
Pass context through function parameters instead of using struct fields, and add nolint directives where non-inherited contexts are intentional (bus lifecycle, mongo sessions, scheduled events).
Zero issues — free to enable.
Suppress intentional context chaining in UnmarshalContext loop.
Add checked type assertions in kafka eventbus, events aggregatestore, and mock tests.
Suppress intentional context embedding in error structs, test mocks, outbox lifecycle context, and event bus lifecycle contexts.
85aeb0a to
c45e35d
Compare
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.
Description
Migrate golangci-lint from v1.42.1 to v2.10.0 and fix all lint issues across the codebase. Update Makefile lint target to read the version from
.tool-versions.Affected Components
.golangci.yml(migrated to v2 format).tool-versions(golangci-lint 2.10.0)Related Issues
None
Solution and Design
Config migration:
.golangci.ymlrewritten for v2 format with explicit linter selection, exclusion presets, and formatters section.Lint fixes by category:
interface{}→any(Go 1.18+)fmt.Errorf("static")→errors.New("static")(perfsprint)for i := 0; i < n; i++→for range n(intrange)maps.Copy,reflect.TypeFor(modernize)//nolintdirectives for acceptable false positives (gosec in tests)skipNonRegisteredEvents)Makefile: Lint target now reads version from
.tool-versionsinstead of hardcoding it.Steps to test and verify
golangci-lint runpasses with zero issuesmake testpassesmake lintuses the version from.tool-versions