Skip to content

chore(lint): adopt golangci-lint #10

Description

@prorochestvo

Context

golangci-lint v2.12.2 was run against this repository using the shared
configuration from the stack-go:lint skill. Nothing in the repository was
changed — this issue records the measurement and the work needed to adopt the
linter permanently.

The run covered the standard linter set only. The custom ruleguard rules were not
included, because they need files inside the repository; expect a few more
findings once they are in place.

Current state

Metric Value
Go files, excluding vendor 74
Total findings 229
Correctness class 87
Style and convention class 142

Most frequent: govet 57, tparallel 46, gocritic 25, paralleltest 24, errcheck 18

What to look at first

The densest correctness bucket in the sweep: 87 of 229 findings. govet
dominates with 57, mostly shadowed err declarations — cmd/yarddog/main.go:64
and :93 both shadow the declaration at line 52. errcheck adds 18.

errorlint reports 8 places formatting an error with %v where %w was
probably meant, which silently breaks errors.Is matching for every caller.

Adoption

  1. Copy .golangci.yml from the stack-go:lint skill assets and fill in the two
    blocks marked PROJECT: forbidden dependencies, and layer boundaries if this
    repository has layers.
  2. Copy gorules/rules.go and run go get github.com/quasilyte/go-ruleguard/dsl.
    The file carries a //go:build ruleguard tag so it never enters a binary, but
    the dependency must be present or the rules fail to typecheck.
  3. Copy scripts/lint-checks.sh for the comment and test-scaffolding rules that
    AST tooling cannot see.
  4. Wire make lint to run golangci-lint run ./... followed by
    scripts/lint-checks.sh.
  5. Add a CI job with the version pinned to v2.12.2. An unpinned linter turns
    someone else's release into a red build on an untouched branch.
  6. Adopt a baseline. With 229 standing findings, a blocking gate on day one
    is a gate that gets switched off in a week. Use --new-from-rev so only new
    code is checked, then clear the backlog by class in separate commits.

Not covered by the linter

These stay manual review items and are documented in the stack-go:lint skill:

  • A jackc/pgx repository layer gets no SQL coverage at all — rowserrcheck and
    sqlclosecheck understand database/sql only.
  • Goroutine ownership: who waits for it, how it is told to stop, where its error
    goes.
  • Whether fan-out is bounded, and whether a channel buffer size has a stated
    reason.
  • Placement of code by actual consumption, and whether two similar blocks share
    an invariant or merely look alike.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions