Repository navigation
Description
Summary
.golangci.yml landed in the v0.10.1 work (there was no lint configuration in this
repository before it, despite GOLANGCI-LINT.md instructing contributors to run against one).
The first full run reports 755 issues, all pre-existing. This issue exists so the backlog
is a tracked number that can go down rather than noise every contributor learns to scroll
past.
Current counts
$ golangci-lint run ./...
755 issues:
* paralleltest: 446 * govet: 57 (all `shadow`) * intrange: 38
* testifylint: 38 * tparallel: 36 * noctx: 35
* contextcheck: 28 * gosec: 26 * errcheck: 13
* exhaustive: 11 * staticcheck: 8 * predeclared: 5
* modernize: 5 * nilerr: 4 * errname: 2
* usetesting: 2 * whitespace: 1
Suggested order, by value per unit of churn
1. paralleltest + tparallel — 482 of the 755 (64%). Mechanical, and CLAUDE.md already
requires t.Parallel() in table-driven tests, so this is enforcing a stated house rule rather
than adopting a new one. Worth doing as its own commit per package so the diff is reviewable;
a package at a time also keeps the risk contained, since adding t.Parallel() to a test with
shared mutable state is how a green suite becomes a flaky one. Any test that cannot be
parallel should get //nolint:paralleltest // <reason> rather than being left to fail —
nolintlint is configured with require-explanation and require-specific, so a bare
//nolint will itself be flagged.
2. errcheck (13), nilerr (4), noctx (35). These are the three that can hide real
defects. nilerr in particular — returning nil after checking a non-nil error — is the exact
shape of several already-fixed v0.10.0 bugs (GetObjects reporting success unless every key
failed; FlushWithContext scheduling and returning nil). Read each one; they are few enough.
3. gosec (26). Mostly G304 (file inclusion via variable) in the persistent cache and
G404 (weak RNG) in fuzz-adjacent test helpers, both of which are correct in context and want
//nolint:gosec with the reason. Anything that is not one of those two deserves a look.
4. govet's shadow (57). All of the form if err := f(); err != nil inside a function
that already has an err. This is idiomatic Go and matches the existing style throughout the
repo. The honest options are to fix them all or to disable shadow with the reason recorded in
.golangci.yml next to the two linters already disabled there (errorlint, dupword).
Leaving 57 issues permanently in the output is the one option that is not honest, because it
trains readers to ignore the tool.
5. The rest — intrange, modernize, testifylint, exhaustive, predeclared,
errname, usetesting, whitespace, staticcheck, contextcheck. Small and mostly
mechanical.
Two that are not lint issues
Worth separating out because they will otherwise sit in this pile:
sdks/c/main.go:60: possible misuse of unsafe.Pointer— this isgo vet, not
golangci-lint, and it is in a cgo shim thatgo testcannot reach. It wants a person who
can reason about the pointer, not a lint pass.internal/cache/predictive.go:600shadows the predeclared identifiererrorwith a local
variable holding a prediction residual. Trivial rename, but it reads as a genuine
legibility bug rather than a style preference.
Not proposed
A blanket //nolint sweep, or setting issues.max-issues-per-linter. Both make the number go
down without making the code better, and the number going down is not the point.
Acceptance
-
golangci-lint run ./...reports 0 issues, or every remaining linter is explicitly
disabled in.golangci.ymlwith its reason recorded in the file - The CI lint job (added in the v0.10.1 work) fails on new issues
- No bare
//nolintdirectives (nolintlintenforces this)
Related
- The
.golangci.ymland the CI lint job it feeds were added in the v0.10.1 harness work;
GOLANGCI-LINT.mdwas deleted at the same time, since it documented a v1-format file that
never existed and its advice now contradicts the shipped v2 config.
Activity
scttfrdmn commentedon Aug 5, 2026
Re-measured against
mainat 90e951a. The backlog is 615, down from 755, and the shape has changed enough that three of this issue's five steps need restating — one is already resolved, and one prescribes a directive form that does not work.Against the original table:
nilerr4 → 0,errname2 → 0,usetesting2 → 0,whitespace1 → 0,staticcheck8 → 6,govet57 → 5,gosec26 → 19,paralleltest446 → 412,tparallel36 → 27,contextcheck28 → 9.intrangewent 38 → 39 — new code, and worth noting the backlog is not monotonic.Step 4 is already done.
govet's remaining 5 findings are notshadow— they areunusedwritein two test files.shadowis disabled in.golangci.ymlwith the reasoning recorded next to it: all 23 findings wereif err := f(); err != nil, the scoped form that prevents the bug shadow exists to catch. That was one of the two honest options this issue named, and it was taken.Step 2's premise does not hold for two of its three linters. This issue calls
errcheck/nilerr/noctx"the three that can hide real defects." Measured:nilerris at 0.noctxfindings are in_test.gofiles — 30 arehttptest.NewRequestinpkg/api/server_test.go, plus twohttp.Get/http.Postand onenet.Listen. A test that cannot cancel its own request is a test-hygiene finding, not a production one.errcheckis 13, of which 3 are non-test:pkg/api/server.go:389and two insdks/c/main.go. The remaining 10 are in_test.go.So the real-defect surface in this category is three lines, not 52. The category is still worth reading — it was right about the class, and
nilerrreaching 0 is partly why — but "read each one" is now a ten-minute job rather than a step.Step 3 prescribes the wrong directive. It says gosec findings "want
//nolint:gosecwith the reason." They do not, and #264/#356 measured why: golangci-lint runs gosec's own analyser, which strips#nosecsites before golangci-lint sees them, so#nosec Gxxx -- reasonalone satisfies both runs — while writing both directives leaves the//nolint:gosecwith nothing to suppress andnolintlintreports it unused. Following step 3 as written turns a suppression into a lint failure. The convention is now written down at.golangci.yml's gosec settings; use that rather than this step.Also from that work: a
// nolintwith a leading space is not a directive at all. Twelve sites across nine files had that form, each with a paragraph of justification attached to nothing, and one of them was concealing a live defect (auint32narrowing that opened the circuit breaker before the first request). Worth knowing before anyone annotates the remaining 19 gosec findings, whose breakdown isG304×11,G404×3,G301×2, and one each ofG302,G306,G118— close to what step 3 predicted.Steps 1 and 5 stand as written.
paralleltest+tparallelare 439 of 615 (71%), still the bulk, still mechanical, and the per-package-commit advice and the shared-mutable-state caution are both right. One correction to step 1's tail: a test that cannot be parallel wants//nolint:paralleltest // <reason>with no space after the slashes, or it is a comment.[-]755 pre-existing golangci-lint issues, 446 of them paralleltest: burn down the backlog the new config surfaced[/-][+]570 pre-existing golangci-lint issues, 385 of them paralleltest: burn down the backlog the new config surfaced[/+]scttfrdmn commentedon Aug 5, 2026
Re-measured on
main— 570, not 755The counts in the body were taken when
.golangci.ymlfirst landed. Six categories have since been resolved outright and every remaining one has shrunk. Title updated; the body's numbers are left as filed, since they are the baseline this issue exists to measure against.What changed, against the filed baseline
shadow)shadowis now explicitly disabled in.golangci.yml, with the evidence recorded: all 23 findings at the time were the scopedif err := f(); err != nilform, which is what prevents the bug shadow exists to find. The 2 remaininggovetfindings are other checks.What this does to the suggested order
Item 4 (
govet'sshadow, 57 findings) is done, and resolved the way that section listed as one of the two honest options — disabled with the reason recorded in the file next to the other two deliberate exclusions.Item 2's most valuable member is also done:
nilerris at zero. That was the one flagged as "the exact shape of several already-fixed v0.10.0 bugs", so it is the right one to have gone first.errcheck(11) andnoctx(31) remain.Item 1 is now 412 of 570 (72%), up from 64% as a share — the mechanical bulk grew proportionally as the substantive findings were fixed. Still the right place for volume, still worth a commit per package for the reason given.
One correction to item 3:
gosecat 14 is no longer "mostlyG304andG404". TwoG404findings ininternal/distributed/consensus.goare known and tracked separately; the rest want individual reading rather than a blanket//nolint.The
predeclaredcount is unchanged at 5, which includes theinternal/cache/predictive.go:600rename called out under "Two that are not lint issues". Still a trivial fix and still not done.scttfrdmn commentedon Aug 6, 2026
Progress: 570 → 299, in #374.
paralleltesttparallelItem 1 of the suggested order — the 72% that was
paralleltest— is now 47% of a much smaller backlog. Seventeen files acrosspkg/errors,pkg/status,pkg/health,pkg/recovery,pkg/retry,pkg/api,pkg/utils,pkg/types,internal/cache,internal/metrics.Two things worth recording, because they are the argument for fixing these rather than suppressing them.
pkg/health'sTestTracker_CanReadwas passing on the order its subtests happened to run in. It wrote a component'sStateand asserted whatCanReadanswered, butadmissionStateadmits one probe oncenextProbehas elapsed and reportsStateDegradedto get it past the gate — soState=StateUnavailablewith a zero-valuenextProbereads as readable. A single shared tracker hid it: the first subtest to reach a refusing state pushednextProbeforward and every later one then read raw state. Isolating per subtest surfaced it asCanRead() = true, want false. Not a production defect —RecordErrorsets both fields — but a test that could not have caught it if they came apart.pkg/utils/debug_mode_test.go's 19 findings are not fixable by at.Parallel().DebugManageris async.Oncesingleton with no exported constructor, andRecordEventbroadcasts to all open sessions, so event counts depend on siblings' traffic — measured asExpected 1 event, got 17and five others, with no data race. Excluded in.golangci.ymlwith the reasoning, and filed as #373 so the exclusion has a route to removal.Remaining 299
intrangeandmodernizeare the next cheapest — purely mechanical, and Go 1.26 makes the rewrite the idiomatic form.noctxandcontextcheckare the ones that want judgment rather than a transform.test: assert what markDegraded records, and unshadow five predeclared…
docs: make six section headers into doc comments that say something
scttfrdmn commentedon Aug 6, 2026
Second batch, in #375 (independent of #372 and #374 — branched off
main, so the three merge in any order).570 → 517 on this branch. Four linters cleared:
intrangetestifylintnoctxpredeclaredstaticcheckmodernizegovetparalleltestalso drops 385 → 384, since the rewrittenTestDegradedStategained at.Parallel().Three findings worth more than their counts
Eight of the 39
intrange/modernizefindings were never ours. Theflattednpm package ships a Go port under its own package directory, so once anything runsnpm install,./...picks up two copies..golangci.ymlnow excludes/node_modules/by path — the same exclusionscripts/coverage-gate.shgrew in #372, and that one is what made these visible.TestDegradedStateasserted that Go assigns struct literal fields. Bothgovetunusedwritefindings were on it. It built aDegradedStateliteral and read two of its own fields back, so its subject was its own fixture — verified by execution: withmarkDegradedreplaced by an empty function body, the old test still passes. Behind it,markDegradedsets seven fields and nothing in the suite asserted any of them. The replacement drives the real producer and fails on five separate mutations.Two of the four doc-comment claims I first wrote were wrong, which is the argument for probing rather than reading.
GetProtocol's comment said its callers are logging sites; it has no callers outside its own package test. AndErrTierNotSupportedis not indistinguishable fromErrInvalid— both wrapos.ErrInvalid, soerrors.Isagainst that can't separate them, buterrors.Is(ErrTierNotSupported, ErrInvalid)is false.Also settled: why
range b.Nand notb.Loop()29 of 31 in-repo
intrangesites are benchmark loops.b.Loopis the Go 1.24+ form and would make the adjacentb.ResetTimer()calls redundant, but that changes what each benchmark measures. The concern that would have forced it doesn't apply:modernize'sbloopanalyzer is in the bundled binary (golangci-lint 2.12.2) and does not fire onrange b.N, even when explicitly enabled — so this trades no finding for another.Remaining 517
paralleltest384 ·testifylint33 ·noctx31 ·tparallel27 ·gosec14 ·errcheck11 ·contextcheck9 ·exhaustive8paralleltest/tparallelare the bulk and #374 already clears 278 of them — the two branches touch disjoint files, so the counts add. Of what's left,testifylintis the next mechanical batch.noctx,contextcheckandexhaustivewant judgment per site rather than a transform, andgosec/errcheckare individual decisions about whether each is real.fix: the assertions a linter would have weakened, and the ones that p…
9 remaining items
test: parallelize seven more packages, and fix the check that hid beh…
test: parallelize internal/storage/s3, the largest remaining cluster
test: give pkg/utils tests a debug manager of their own
fix(recovery): copy AttemptCount under the lock that writes it
test: parallelize internal/cache
test: parallelize pkg/api
fix(tests): synchronize a test backend's counters, and parallelize th…
test: t.Parallel across seventeen files, and one test that passed by …
feat(s3): a write that happens only if an assertion about the key hol…
refactor(fuse): delete ReadAheadManager.Stop and its channel (#376) (#…
refactor(cache): delete redis's pub/sub Invalidator, which deleted fr…
chore: a docs path that never existed, and four duplicate link defini…
chore: a docs path that never existed, and four duplicate link defini…
chore: a docs path that never existed, and four duplicate link defini…