feat: enable modernize linter in golangci-lint and fix all violations#9798
Open
mmorel-35 wants to merge 1 commit into
Open
feat: enable modernize linter in golangci-lint and fix all violations#9798mmorel-35 wants to merge 1 commit into
mmorel-35 wants to merge 1 commit into
Conversation
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Contributor
Author
|
/kind changelog-not-required |
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.
Please add a summary of your change
Enables the
modernizelinter in the golangci-lint configuration and fixes all reported violations across the codebase. Themodernizelinter is part ofgolangci-lintsince v2.1.0 and the project already uses v2.12.0, so no tooling version bump is needed.Changes to
.golangci.yamlmodernizeto thelinters.enablelistnewexprcheck vialinters.settings.modernize.disable(placed in alphabetical order withinlinters.settings) — the golangci-lint auto-fix fornewexprgenerates syntactically invalid Go code (new(literal_value)—newonly accepts types, not values), making it unsafe to enableFixes applied across 49 Go files
mapsloopfor k, v := range src { dst[k] = v }withmaps.Copyslicescontainsslices.Containsstringsseqfor _, s := range strings.Split(...)withstrings.SplitSeqstringscutstrings.Indexpatterns withstrings.Cutrangeintfor i := 0; i < n; i++ {}withfor range n {}fmtappendf[]byte(fmt.Sprintf...)withfmt.Appendf(nil, ...)plusbuild// +buildlines (replaced by//go:build)minmaxmax()/min()builtinsomitzeroomitempty(no-op for struct fields) withomitzeroslicesbackwardslices.Backwardwaitgroupgowg.Add(1); go func() { defer wg.Done() ... }()withwg.Go(...)atomictypesvar x int32+atomic.*Int32calls withatomic.Int32Please indicate you've done the following:
make new-changelog) or comment/kind changelog-not-requiredon this PR.site/content/docs/main.