Skip to content

chore(lint): make discarded Close and Fprint errors explicit - #13

Merged
prorochestvo merged 1 commit into
mainfrom
chore/10-errcheck-clean
Aug 13, 2026
Merged

chore(lint): make discarded Close and Fprint errors explicit#13
prorochestvo merged 1 commit into
mainfrom
chore/10-errcheck-clean

Conversation

@prorochestvo

Copy link
Copy Markdown
Owner

Refs: #10

Clears every errcheck finding in the tree. golangci-lint run ./... goes from 17
issues to 0; make test and make lint stay green; no behaviour changes.

What these findings were

All of them dropped an error implicitly. None was a latent bug — each is a
deliberate discard:

Site Why the error is uninteresting
infrastructure/env.go the env file is opened for reading
infrastructure/check.go TCP conn closed after its latency was already measured
infrastructure/store.go, store_test.go sql.Rows; a real failure also surfaces through the scan
gateway/router/nokia.go, gateway/telegram/telegram.go HTTP body already read to completion
gateway/router/nokia_test.go httptest handler writes

So the fix states the discard instead of handling it, using the form the codebase
already uses in store.go:

defer func() { _ = rows.Close() }()

No comments were added at these sites: _ = already says "deliberately dropped",
and the existing comments in store.go earn their place only because
"rollback after commit" is genuinely non-obvious, which Close is not.

On the count

The first run reported 13 issues, the fixed tree then reported 4 more, and the true
total was 17. golangci-lint caps repeats of an identical message at three
(max-same-issues), so the initial number understated the work. Re-run uncapped to
see the real state:

golangci-lint run ./... --max-issues-per-linter=0 --max-same-issues=0

Every occurrence in each touched file was converted, not only the reported ones, so
the files are internally consistent rather than half-converted.

Scope

This does not adopt golangci-lint — no .golangci.yml, no CI job, no
ruleguard, and nothing added to go.mod. It only makes the tree clean under the
linter's default set (errcheck, govet, ineffassign, staticcheck, unused),
of which the other four were already clean.

Worth noting for #10: the 229-finding sweep recorded there comes from the shared
stack-go:lint configuration, and step 2 of its adoption plan pulls in
github.com/quasilyte/go-ruleguard/dsl. That conflicts with the stdlib-only rule in
CLAUDE.md (modernc.org/sqlite is the sole permitted dependency), even
build-tagged, so adoption needs that decision made first.

golangci-lint's errcheck flagged deferred `Close` calls and test-server
`Fprint` writes whose errors were dropped implicitly. Every site is a
deliberate discard, not a latent bug: a file opened for reading, a TCP
conn closed after its latency was measured, `sql.Rows` whose error also
surfaces through the scan, an HTTP body already read to completion, and
`httptest` handler writes.

So state the discard rather than handle it, matching the
`defer func() { _ = tx.Rollback() }()` form already used in store.go. No
behaviour changes.

Applied to every occurrence in each file, not only the reported ones:
golangci-lint caps repeats of one message at three by default, so the
run understated the real count (17, not the 13 first shown). Uncapped,
`golangci-lint run ./...` is now at 0 issues.

Refs: #10
@prorochestvo
prorochestvo merged commit bf5f1f8 into main Aug 13, 2026
1 check passed
@prorochestvo
prorochestvo deleted the chore/10-errcheck-clean branch August 13, 2026 04:40
prorochestvo added a commit that referenced this pull request Aug 13, 2026
plans/plan_review_20260718.txt was added to the tree by mistake in #13:
that commit staged with `git add -A`, which swept up a working note that
had deliberately sat untracked. It is neither a plan under the
plans/{completed,history} convention nor English-language repository
content.

Remove it from version control. The file stays on disk, untracked, as it
was before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant