Repository navigation
Conversation
fc37825 to
d349cfc
Compare
hectorhuertas
left a comment
There was a problem hiding this comment.
Reviewed at 35c285d. I ran the tooling locally and reproduced the PR's claims: golangci-lint v2.15.0 run → 0 issues, make lint → 0 issues, go test ./... passes. And answering the open question in the description: docker build . succeeds end-to-end (tests + lint + build, ~154s; no toolchain download needed because golang:1.27-alpine currently ships exactly go1.27.3).
Migration is sound overall: version: "2", gas→gosec, gofmt→formatters, default: none with govet/ineffassign listed explicitly, and correctly not copying migrate's "disable staticcheck/unused" artefact (that's what golangci-lint migrate emits because of the legacy megacheck entry — good call ignoring it; note migrate can't run on this file at all since it rejects run.skip-*/output.format, so the hand migration was necessary).
Should fix
1. .golangci.yml:30-33 — checks: ["all", "-S*", "-ST*"] also enables the QF checks, contrary to the comment
v2 folds gosimple (S), stylecheck (ST) and quickfix (QF) into staticcheck, and all includes QF — which v1 never ran. Verified with a probe file:
p/a.go:13:5: QF1001: could apply De Morgan's law (staticcheck)
The stated intent ("keep only the SA checks") is exactly checks: ["SA*"]. I patched that in and the repo is still 0 issues, so it's a safe drop-in.
2. Makefile:35-37 — a failed wget is masked by the pipe, so make lint fails later with a confusing message
wget … | sh -s … returns sh's exit status, so a failed download "succeeds", and lint then dies with make: ./bin/golangci-lint: No such file or directory (I reproduced this by making wget fail). Given this PR is about deterministic installs, worth hardening:
@if ! ./bin/$(LINTER) version 2>/dev/null | grep -qwF "$(LINTER_VERSION:v%=%)"; then \
wget -O $(LINTER).install.sh -q https://raw.githubusercontent.com/golangci/golangci-lint/$(LINTER_VERSION)/install.sh && \
sh $(LINTER).install.sh -s $(LINTER_VERSION) && test -x ./bin/$(LINTER); \
fi(or set -o pipefail via SHELL := /bin/bash). The same wget | sh pattern is in the Dockerfile:14; there the next command at least fails, but with a misleading error.
Nits / suggestions
run.timeoutis unset. In v2 the default is disabled (--timeout: "Disabled by default"). v1'sdeadline: 20sis gone and the Dockerfile runsgolangci-lint runwith no--timeout(only the Makefile passes--timeout=10m), so the build-stage lint can now hang indefinitely. Considerrun.timeout: 10min the config.cmd_test.go, while you're in there:TestDumperFromFlags_Timeout(L120) still uses the prefix"TestDumperFromFlags_ValidBinaryPath"(copy-paste), and neither temp file isClose()d beforeos.Remove—defer f.Close()avoids leaking an fd for the test process.Dockerfile:8-11, GOTOOLCHAIN pin — worth one more line in the comment. It's an exact pin: today's base image already has 1.27.3 so nothing downloads, but oncegolang:1.27-alpinefloats to 1.27.4+, every build will download the 1.27.3 toolchain (~100 MB) from the proxy. That's the intended trade-off, it just isn't obvious from the comment as written.- Pre-existing, now more visible: the deleted line was the only reader of
CliDumper.Flags, so--dbcli-flagsis accepted and silently ignored (thepg_dumpbranch builds its args without it). Follow-up: wire it into the args or drop the flag + field. .golangci.yml:37-40paths: [contract, '\.pb\.go']— a barecontractalso matches e.g.internal/contracts/;^contract/is tighter. Also the v1 implicit default dir exclusions are gone entirely (vendor$,testdata$, …). FYI I tested thethird_party$/builtin$/examples$set thatmigrateemits: it does not actually exclude files inside those dirs (only a bareexamplesregex does), and no such dirs exist here — so no practical impact, just don't be surprised.bin/isn't in.gitignore, somake lintleaves an untrackedbin/behind (pre-existing, one-line fix).
Verified as correct
- The two
//nolint:errcheckadditions are genuinely required: v2's errcheck added channel-receive checking — removing them yields exactly those 2 errors. Correctly scoped and documented. - Makefile version detection: parses
ENV GOLANGCI_LINT_VERSION="…"from the Dockerfile, strips thev,grep -qwFs the installed binary's version, and reinstalls on mismatch (verified by faking a1.0.0binary). Fails loudly when the Dockerfile line is absent. errBuff.String(),os.CreateTempand the dead-dumpCmdremoval are behaviour-preserving (exec.Commanddoes its ownLookPath; the switch'sdefault:returns beforedumpCmdis dereferenced, so no nil-pointer risk).
Nothing here is a blocker IMO — items 1 and 2 are the only ones I'd want in before merge.
.golangci.yml: v2 format (gas→gosec,gofmtas a formatter,check-shadowing→govet.enable: [shadow]).contractand.pb.gopath skips kept.
govetandineffassignlisted explicitly (implicit v1 defaults).staticcheckpinned to the SA checks (all,-S*,-ST*). v2 mergesgosimpleandstylecheckinto it, andv1 had both off.
Dockerfile/Makefile: version pinned to v2.15.0 and the install script fetched from the tag, notmaster.The Makefile reads the version from the Dockerfile, fails if it's missing, and reinstalls on version mismatch.
Dockerfile:GOTOOLCHAINis now exported. It was a plain shell variable, so the pinned toolchain was neverapplied.
cli.go: removed deadexec.LookPath/exec.Command(dumpCmdwas always reassigned, so no behaviourchange). Use
errBuff.String(). Scoped//nolint:errcheckon the two<-doneChreceives, which v2 flags.cmd_test.go:ioutil.TempFile→os.CreateTemp.golangci-lint runon v2.15.0: 0 issues.go test ./...passes.docker build .: to confirm before merge. CI only runs the Docker lint step on push to master.