chore(lint): enable testifylint and thelper, and fix what they found - #6984
Merged
Conversation
216 findings, and one of them was a bug. Two httptest handlers called require.NoError, which reaches t.FailNow from a goroutine that is not the test's. FailNow is only defined on the test goroutine, so a failed upgrade there would not have stopped the test the way the code reads — it now asserts and returns instead. The other 125 are the same shape: an error asserted with assert, then the value it produced dereferenced on the next line. When the assertion fails the test keeps going and panics on nil, reporting a crash instead of the assertion that actually failed. require stops at the assertion. thelper accounts for 91. Helpers that take a *testing.T now say so, which makes a failure point at the caller rather than at the line inside the helper. The storetest sub-suite closures took *testing.T second; they take it first now, and runSubSuite's signature follows. The rewrites came from the linter's own file:line output rather than by hand, then the whole suite was run to confirm no assertion changed a result.
|
Claude finished @otavio's task in 4m 59s —— View job Code Review CompleteReviewed 63 files across code quality, security, testing, language patterns, and architecture — no new issues found. The code looks good as-is. The change is mechanical and test-only. I verified the parts that carry actual semantic weight:
To request another review round, comment |
otavio
commented
Aug 28, 2026
The script that added the require imports appended each one as its own blank-line-separated group instead of joining the existing testify group. goimports preserves the grouping it is given, so nothing flagged it.
goimports preserves whatever grouping it is handed, so an import added in a block of its own stays there and reads as a deliberate section. That is how the stray testify groups in this branch survived a clean lint, a clean vet and a full test run, and it took a human reading the diff to catch them. gci decides the grouping instead of accepting it: one standard block, one for everything else. That also flattens the two blocks this repo had split on purpose, including the caddy-dns providers in the gateway, whose comment now names the imports it describes rather than relying on the blank line above them.
otavio
added a commit
that referenced
this pull request
Aug 28, 2026
The script that added the require imports appended each one as its own blank-line-separated group instead of joining the existing testify group. goimports preserves the grouping it is given, so nothing flagged it.
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
testifylintandthelper, and fixes the 216 findings they report across 63 files. All of it is test code.Why
Fourth step of the lint expansion, after #6980, #6981 and #6982. These two are what make a failing test say the right thing: the assertion that failed, at the caller's line, instead of a nil panic three lines later.
Changes
One real bug. Two
httptesthandlers calledrequire.NoError— inpkg/wsconnadapterandserver/ssh/pkg/dialer.requirereachest.FailNow, which is only defined on the test's own goroutine. A failed WebSocket upgrade in those handlers would not have stopped the test the way the code reads. They now assert and return.125
require-error. The recurring shape is an error asserted withassert, then the value it produced dereferenced on the next line. When the assertion fails the test keeps running and panics on nil, so the report is a crash rather than the assertion that actually failed.requirestops there instead.tests/environmenthad this hand-rolled seven times asif !assert.NoError(t, err) { assert.FailNow(t, err.Error()) }, which isrequire.NoErrorwritten out longhand. Those collapse to the real thing.91
thelper. Helpers that take a*testing.Tnow declare it, so a failure points at the caller rather than at a line inside the helper. Thestoretestsub-suite closures took*testing.Tsecond, whichthelperreads as a helper with its parameters the wrong way round — they take it first now andrunSubSuite's signature follows.How
The rewrites were driven from the linter's own
file:lineoutput rather than typed, then the full suite was run to confirm no assertion changed a result. Two mechanical slips the process caught and I fixed: at.Helper()insertion that landed in a composite literal because the target was a single-line empty closure, and 58 duplicatedtestifyimports from the import pass.Testing
Under
golang:1.26.7-alpine3.24:golangci-lint run ./...reports0 issuesfor all six modules, and foragentunder no tags,-tags dockerand-tags nativego build ./...clean everywherego test ./...passes for root,server, andagentunder bothdockerandnativego vet ./...clean;go mod tidya no-ophttps://claude.ai/code/session_01D4BSojj4fmh3ZQSZWkGbD8