Add golangci-lint gate and fix its findings

Configure golangci-lint v2 for the whole tree (brlapi/duckdb build tags, curated linters, documented exclusions) and resolve what it reports: dead code, wrapped-error comparisons and %w wrapping, unclosed websocket handshake bodies, staticcheck SA/S items, ineffectual assignments, and explicit _ = discards for best-effort teardown errors. Document the gate in CONTRIBUTING and AGENTS.
This commit is contained in:
hjozwiak committed 2026-11-10 21:13:49 -05:00
1 parent b03cb8917d
commit 0459fb8e50
43 files changed
+166 -112

No files matched your search

+14
View File
@@ -41,6 +41,7 @@ go test ./... -count=1
go test -race ./... -count=1
go test -tags brlapi ./... -count=1
go vet ./...
golangci-lint run ./...
go build ./cmd/...
go run ./cmd/parityledger validate testdata/parity-ledger.csv
```
@@ -54,6 +55,19 @@ they use isolated fake tools and require no network or running reader.
Start verification with the affected packages; run broader checks when the change affects shared behavior or before submission where practical. Format edited Go files with `gofmt`; run `shellcheck` for edited shell scripts. Use deterministic tests and synchronization instead of timing sleeps. Keep fixtures generic, without real usernames or personal identifiers.
Lint with `golangci-lint run ./...` before submission. The configuration in
`.golangci.yml` is v2-schema and already sets the `brlapi` and `duckdb`
build tags, so tagged native files are analyzed; that needs the same
development libraries as the Arch `PKGBUILD`, including BrlAPI/liblouis and
the DuckDB headers. Keep `golangci-lint` built with a Go version at least
as new as the project toolchain: an older linter cannot decode current
export data and reports spurious typecheck errors. Deliberate exclusions
(cleanup `Close` calls, test-fixture error handling, style checks that
conflict with complete user-facing messages) are documented in the config;
do not weaken them to silence a finding that should be fixed in code
instead. Lint is a development gate only and is not run by the Arch package
`check()`, so distribution linter updates cannot break package builds.
### Version update pre-commit hook
The optional `hooks/pre-commit` hook updates the Go `Version` constant to the