Skip to content

570 pre-existing golangci-lint issues, 385 of them paralleltest: burn down the backlog the new config surfaced #179

Closed

Description

@scttfrdmn

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 is go vet, not
    golangci-lint, and it is in a cgo shim that go test cannot reach. It wants a person who
    can reason about the pointer, not a lint pass.
  • internal/cache/predictive.go:600 shadows the predeclared identifier error with 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.yml with its reason recorded in the file
  • The CI lint job (added in the v0.10.1 work) fails on new issues
  • No bare //nolint directives (nolintlint enforces this)

Related

  • The .golangci.yml and the CI lint job it feeds were added in the v0.10.1 harness work;
    GOLANGCI-LINT.md was 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

  1. added this to the Future Work milestone on Aug 1, 2026
  2. added
    type: technical-debt
    priority: medium
    area: core
    on Aug 1, 2026
  3. added
    effort: medium
    on Aug 3, 2026
  4. scttfrdmn commented on Aug 5, 2026

    @scttfrdmn
    OwnerAuthor

    Re-measured against main at 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.

    $ golangci-lint run
    615 issues:
    * paralleltest: 412    * testifylint: 33    * noctx: 33
    * intrange: 39         * tparallel: 27      * gosec: 19
    * errcheck: 13         * contextcheck: 9    * exhaustive: 8
    * modernize: 6         * staticcheck: 6     * predeclared: 5
    * govet: 5
    

    Against the original table: nilerr 4 → 0, errname 2 → 0, usetesting 2 → 0, whitespace 1 → 0, staticcheck 8 → 6, govet 57 → 5, gosec 26 → 19, paralleltest 446 → 412, tparallel 36 → 27, contextcheck 28 → 9. intrange went 38 → 39 — new code, and worth noting the backlog is not monotonic.

    Step 4 is already done. govet's remaining 5 findings are not shadow — they are unusedwrite in two test files. shadow is disabled in .golangci.yml with the reasoning recorded next to it: all 23 findings were if 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:

    • nilerr is at 0.
    • All 33 noctx findings are in _test.go files — 30 are httptest.NewRequest in pkg/api/server_test.go, plus two http.Get/http.Post and one net.Listen. A test that cannot cancel its own request is a test-hygiene finding, not a production one.
    • errcheck is 13, of which 3 are non-test: pkg/api/server.go:389 and two in sdks/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 nilerr reaching 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:gosec with the reason." They do not, and #264/#356 measured why: golangci-lint runs gosec's own analyser, which strips #nosec sites before golangci-lint sees them, so #nosec Gxxx -- reason alone satisfies both runs — while writing both directives leaves the //nolint:gosec with nothing to suppress and nolintlint reports 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 // nolint with 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 (a uint32 narrowing that opened the circuit breaker before the first request). Worth knowing before anyone annotates the remaining 19 gosec findings, whose breakdown is G304 ×11, G404 ×3, G301 ×2, and one each of G302, G306, G118 — close to what step 3 predicted.

    Steps 1 and 5 stand as written. paralleltest + tparallel are 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.

  5. changed the title [-]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[/+] on Aug 5, 2026
  6. scttfrdmn commented on Aug 5, 2026

    @scttfrdmn
    OwnerAuthor

    Re-measured on main — 570, not 755

    The counts in the body were taken when .golangci.yml first 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.

    $ golangci-lint run ./...
    570 issues:
    * paralleltest: 385    * intrange: 37     * testifylint: 33
    * noctx: 31            * tparallel: 27    * gosec: 14
    * errcheck: 11         * contextcheck: 9  * exhaustive: 8
    * staticcheck: 6       * predeclared: 5   * govet: 2
    * modernize: 2
    

    What changed, against the filed baseline

    linter filed now
    paralleltest 446 385 −61
    govet (shadow) 57 2 shadow is now explicitly disabled in .golangci.yml, with the evidence recorded: all 23 findings at the time were the scoped if err := f(); err != nil form, which is what prevents the bug shadow exists to find. The 2 remaining govet findings are other checks.
    noctx 35 31 −4
    tparallel 36 27 −9
    gosec 26 14 −12
    contextcheck 28 9 −19
    testifylint 38 33 −5
    intrange 38 37 −1
    errcheck 13 11 −2
    exhaustive 11 8 −3
    staticcheck 8 6 −2
    modernize 5 2 −3
    nilerr 4 0 gone
    errname 2 0 gone
    usetesting 2 0 gone
    whitespace 1 0 gone
    predeclared 5 5 unchanged

    What this does to the suggested order

    Item 4 (govet's shadow, 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: nilerr is 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) and noctx (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: gosec at 14 is no longer "mostly G304 and G404". Two G404 findings in internal/distributed/consensus.go are known and tracked separately; the rest want individual reading rather than a blanket //nolint.

    The predeclared count is unchanged at 5, which includes the internal/cache/predictive.go:600 rename called out under "Two that are not lint issues". Still a trivial fix and still not done.

  7. scttfrdmn commented on Aug 6, 2026

    @scttfrdmn
    OwnerAuthor

    Progress: 570 → 299, in #374.

    before after
    total 570 299
    paralleltest 385 134
    tparallel 27 7
    everything else 158 158

    Item 1 of the suggested order — the 72% that was paralleltest — is now 47% of a much smaller backlog. Seventeen files across pkg/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's TestTracker_CanRead was passing on the order its subtests happened to run in. It wrote a component's State and asserted what CanRead answered, but admissionState admits one probe once nextProbe has elapsed and reports StateDegraded to get it past the gate — so State=StateUnavailable with a zero-value nextProbe reads as readable. A single shared tracker hid it: the first subtest to reach a refusing state pushed nextProbe forward and every later one then read raw state. Isolating per subtest surfaced it as CanRead() = true, want false. Not a production defect — RecordError sets 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 a t.Parallel(). DebugManager is a sync.Once singleton with no exported constructor, and RecordEvent broadcasts to all open sessions, so event counts depend on siblings' traffic — measured as Expected 1 event, got 17 and five others, with no data race. Excluded in .golangci.yml with the reasoning, and filed as #373 so the exclusion has a route to removal.

    Remaining 299

      134  paralleltest      in packages not yet touched
       37  intrange          mechanical: for i := 0; i < n; i++  →  for i := range n
       33  testifylint
       31  noctx
       14  gosec
       11  errcheck
        9  contextcheck
        8  exhaustive
        7  tparallel
        6  staticcheck
        5  predeclared
        2  govet
        2  modernize
    

    intrange and modernize are the next cheapest — purely mechanical, and Go 1.26 makes the rewrite the idiomatic form. noctx and contextcheck are the ones that want judgment rather than a transform.

  8. scttfrdmn commented on Aug 6, 2026

    @scttfrdmn
    OwnerAuthor

    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:

    linter before after
    intrange 37 0
    testifylint 33 33
    noctx 31 31
    predeclared 5 0
    staticcheck 6 0
    modernize 2 0
    govet 2 0

    paralleltest also drops 385 → 384, since the rewritten TestDegradedState gained a t.Parallel().

    Three findings worth more than their counts

    Eight of the 39 intrange/modernize findings were never ours. The flatted npm package ships a Go port under its own package directory, so once anything runs npm install, ./... picks up two copies. .golangci.yml now excludes /node_modules/ by path — the same exclusion scripts/coverage-gate.sh grew in #372, and that one is what made these visible.

    TestDegradedState asserted that Go assigns struct literal fields. Both govet unusedwrite findings were on it. It built a DegradedState literal and read two of its own fields back, so its subject was its own fixture — verified by execution: with markDegraded replaced by an empty function body, the old test still passes. Behind it, markDegraded sets 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. And ErrTierNotSupported is not indistinguishable from ErrInvalid — both wrap os.ErrInvalid, so errors.Is against that can't separate them, but errors.Is(ErrTierNotSupported, ErrInvalid) is false.

    Also settled: why range b.N and not b.Loop()

    29 of 31 in-repo intrange sites are benchmark loops. b.Loop is the Go 1.24+ form and would make the adjacent b.ResetTimer() calls redundant, but that changes what each benchmark measures. The concern that would have forced it doesn't apply: modernize's bloop analyzer is in the bundled binary (golangci-lint 2.12.2) and does not fire on range b.N, even when explicitly enabled — so this trades no finding for another.

    Remaining 517

    paralleltest 384 · testifylint 33 · noctx 31 · tparallel 27 · gosec 14 · errcheck 11 · contextcheck 9 · exhaustive 8

    paralleltest/tparallel are the bulk and #374 already clears 278 of them — the two branches touch disjoint files, so the counts add. Of what's left, testifylint is the next mechanical batch. noctx, contextcheck and exhaustive want judgment per site rather than a transform, and gosec/errcheck are individual decisions about whether each is real.

  9. 9 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreeffort: mediumpriority: mediumtype: technical-debt

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions