chore(lint): enable perfsprint and usetesting, and apply their rewrites - #6982
Merged
Conversation
|
Claude finished @otavio's task in 1m 28s —— View job Code Review CompleteReviewed 24 files across code quality, security, testing, language patterns, and architecture — no new issues found. The code looks good as-is. This is a mechanical
Good call excluding To request another review round, comment |
Both carry autofixes, so almost every hunk here was written by the linter: Sprintf calls that only concatenate become concatenation, Errorf with no verbs becomes errors.New, and %x over a byte slice becomes hex.EncodeToString. pkg/envs was the one that needed hands. Its table-driven cases set the environment through a before closure and undid it through a matching after, neither of which takes a *testing.T, so the fix could not be mechanical. The cases now take one and call t.Setenv, which restores the previous value when the subtest ends — the teardown the after closures were doing by hand, so they are gone. dupword was in this group and is left out. Its autofix rewrites duplicated tokens inside test fixtures, where the repetition is the data: it stripped the filesystem type from a mountinfo sample and turned "now(), now()" in a SQL insert into a single call, changing the statement's column count.
otavio
force-pushed
the
chore/lint-idiom
branch
from
August 28, 2026 20:15
982ed52 to
f969487
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.
What
Enables
perfsprintandusetesting, and applies the ~200 rewrites they report.Why
Third step of the lint expansion, after #6980 and #6981. Both linters carry autofixes, so almost every hunk here was written by the tool rather than by hand — review the diff, not the reasoning behind each line.
perfsprint—fmt.Sprintfused where concatenation orstrconvdoes the job,fmt.Errorfwith no format verbs whereerrors.Newbelongs, andfmt.Sprintf("%x", b)wherehex.EncodeToStringis both clearer and faster.usetesting—t.Setenv,t.Context()andt.TempDir()over the hand-rolled equivalents.Changes
One file needed hands.
pkg/envs/envs_test.goset the environment through abeforeclosure and undid it through a matchingafter, neither of which takes a*testing.T, so the fix could not be mechanical. Those cases now take one and callt.Setenv, which restores the previous value when the subtest ends. That is exactly what theafterclosures did by hand, so they are gone — 4 test tables, ~40 lines of teardown deleted.Everything else is the linter's output, plus one tidy-up:
perfsprintleft five"/api/devices/" + "3a47..."pairs of adjacent literals, which I merged.Not included
dupwordwas in this group and is deliberately left out. Its autofix corrupts test fixtures, because in fixture data the repetition is the data. Applied to this tree it:/proc/self/mountinfosample inpkg/dockerutils/utils_test.go, stripping the filesystem type where the format legitimately repeats it (- overlay overlay rw,...became- overlay rw,...)VALUES (..., now(), now(), ...)intonow()in threemigrations_test.goinserts, changing the statement's column count, and mangled a string concatenation into,"+ownerID+' in the processBoth would have compiled. Neither is a change anyone would approve on purpose.
Testing
Under
golang:1.26.7-alpine3.24:golangci-lint run ./...reports0 issuesfor all six modulesgo build ./...clean everywhere, plusagentunder-tags dockerand-tags nativego test ./...passes for root,server, andagentunder-tags dockergo mod tidyis a no-ophttps://claude.ai/code/session_01D4BSojj4fmh3ZQSZWkGbD8