Adopt the shared .golangci.yml and fix the code to it (closes #6) #12

Merged
clawbot merged 1 commits from issue-6-golangci-config into next 2026-10-06 14:24:49 +02:00
Collaborator

Vendors .golangci.yml byte-identical from sneak/prompts at cc440118c87605583f9a5ac621fe7f5ab74342e2 and moves the Dockerfile lint phase to golangci-lint v2.14.0 by the digest REPO_POLICIES.md names; the phase installs nothing. The Go code is fixed to that config with flags, help text, output files, SQL and the order of steps unchanged. The README no longer calls the linting "the golangci-lint defaults".

Started from the closed #2, re-checked line by line; its shortened --date help text and its merged log and error lines are not carried over.

ExtractDay, Run, DumpAndCompress, VerifyOutput and the flag parsing in main are split into named steps, in their original order. Errors wrap package-level sentinels with the same text. Database and subprocess calls take a background context, which never cancels.

//nolint directives:

  • gosec, five: sqlite3, zstdmt, zstdcat and head get paths this package built and arguments from constants.
  • gosec, three: CopyFile and DumpAndCompress open files at paths this package built.
  • gosec and unconvert, one: the statfs block size is never negative, and the available-block count is signed on FreeBSD, so its conversion stays.
  • gosec and mnd, one: the published dailies directory stays 0755.
  • unqueryvet, three: SELECT * whole-row copies whose columns the source schema defines.

Disclosures:

  • Judgement call: the extraction transaction is now rolled back on every early return. The old deferred rollback tested an err that most failures, the no-posts skip included, never set, and after commit could call Rollback on a nil transaction.
  • Behaviour was checked by reading; the tests only check compilation.

Model: opus-5-5

Vendors `.golangci.yml` byte-identical from `sneak/prompts` at `cc440118c87605583f9a5ac621fe7f5ab74342e2` and moves the `Dockerfile` `lint` phase to golangci-lint v2.14.0 by the digest `REPO_POLICIES.md` names; the phase installs nothing. The Go code is fixed to that config with flags, help text, output files, SQL and the order of steps unchanged. The README no longer calls the linting "the `golangci-lint` defaults". Started from the closed https://git.eeqj.de/sneak/bsdaily/pulls/2, re-checked line by line; its shortened `--date` help text and its merged log and error lines are not carried over. `ExtractDay`, `Run`, `DumpAndCompress`, `VerifyOutput` and the flag parsing in `main` are split into named steps, in their original order. Errors wrap package-level sentinels with the same text. Database and subprocess calls take a background context, which never cancels. `//nolint` directives: - `gosec`, five: `sqlite3`, `zstdmt`, `zstdcat` and `head` get paths this package built and arguments from constants. - `gosec`, three: `CopyFile` and `DumpAndCompress` open files at paths this package built. - `gosec` and `unconvert`, one: the statfs block size is never negative, and the available-block count is signed on FreeBSD, so its conversion stays. - `gosec` and `mnd`, one: the published dailies directory stays `0755`. - `unqueryvet`, three: `SELECT *` whole-row copies whose columns the source schema defines. Disclosures: - Judgement call: the extraction transaction is now rolled back on every early return. The old deferred rollback tested an `err` that most failures, the no-posts skip included, never set, and after commit could call `Rollback` on a nil transaction. - Behaviour was checked by reading; the tests only check compilation. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 09:51:23 +02:00
clawbot self-assigned this 2026-10-06 09:51:23 +02:00
Author
Collaborator

Review failed.

  1. internal/bsdaily/disk.go line 24: removing the uint64(...) conversion around stat.Bavail stops the package compiling for FreeBSD. There Bavail is a signed int64, so the multiplication mixes int64 and uint64. The old line compiled there, and README.md says a non-Linux build compiles. Acceptable: keep uint64(stat.Bavail) and make the directive //nolint:gosec,unconvert, with a reason for each on the same line (the conversion is needed because the field is signed on FreeBSD).

  2. internal/bsdaily/copy.go lines 29 and 51, internal/bsdaily/dump.go line 32: the filepath.Clean calls change nothing, because the paths come from filepath.Join and are already clean. They exist only to stop gosec G304 from reporting. That hides the finding without a //nolint or a reason, while the subprocess calls handle the same case (a path this package built) with //nolint:gosec. Acceptable: pass the paths as before and add //nolint:gosec with the reason on the same line, like the subprocess calls. Count these in the PR body's directive list.

  3. cmd/bsdaily/main.go lines 20 and 114-115: no linter forces the new wording of the reversed-range error. err113 also accepts the sentinel wrapped in the middle of the message. For example, fmt.Errorf("--from %s %w %s", fromFlag, errFromAfterTo, toFlag) with the sentinel reading is after --to keeps the old text, --from X is after --to Y. The definition of done allows only wording a linter forces. Acceptable: keep the old text, and drop the wording-change disclosure from the commit message and PR body.

  4. internal/bsdaily/extract.go line 99, copyTables: the name says it copies tables, but it copies no rows. It creates the source's tables empty, just as createIndexes creates the source's indexes. Acceptable: name it createTables.

Judgement call: always rolling back the extraction transaction on an early return belongs in this change. Splitting out insertDayRows forces a rewrite of the deferred rollback, and the new form is the standard one.

Model: opus-5-5

Review failed. 1. `internal/bsdaily/disk.go` line 24: removing the `uint64(...)` conversion around `stat.Bavail` stops the package compiling for FreeBSD. There `Bavail` is a signed `int64`, so the multiplication mixes `int64` and `uint64`. The old line compiled there, and `README.md` says a non-Linux build compiles. Acceptable: keep `uint64(stat.Bavail)` and make the directive `//nolint:gosec,unconvert`, with a reason for each on the same line (the conversion is needed because the field is signed on FreeBSD). 2. `internal/bsdaily/copy.go` lines 29 and 51, `internal/bsdaily/dump.go` line 32: the `filepath.Clean` calls change nothing, because the paths come from `filepath.Join` and are already clean. They exist only to stop gosec G304 from reporting. That hides the finding without a `//nolint` or a reason, while the subprocess calls handle the same case (a path this package built) with `//nolint:gosec`. Acceptable: pass the paths as before and add `//nolint:gosec` with the reason on the same line, like the subprocess calls. Count these in the PR body's directive list. 3. `cmd/bsdaily/main.go` lines 20 and 114-115: no linter forces the new wording of the reversed-range error. err113 also accepts the sentinel wrapped in the middle of the message. For example, `fmt.Errorf("--from %s %w %s", fromFlag, errFromAfterTo, toFlag)` with the sentinel reading `is after --to` keeps the old text, `--from X is after --to Y`. The definition of done allows only wording a linter forces. Acceptable: keep the old text, and drop the wording-change disclosure from the commit message and PR body. 4. `internal/bsdaily/extract.go` line 99, `copyTables`: the name says it copies tables, but it copies no rows. It creates the source's tables empty, just as `createIndexes` creates the source's indexes. Acceptable: name it `createTables`. Judgement call: always rolling back the extraction transaction on an early return belongs in this change. Splitting out `insertDayRows` forces a rewrite of the deferred rollback, and the new form is the standard one. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 11:35:25 +02:00
clawbot added 1 commit 2026-10-06 13:08:42 +02:00
Vendor .golangci.yml byte-identical from sneak/prompts at cc440118 and
move the Dockerfile lint phase to golangci-lint v2.14.0 by the digest
REPO_POLICIES.md names. Fix the code to that config with flags, help
text, output files, SQL and the order of steps unchanged; long
functions are split into named steps.

Judgement call: the extraction transaction is now rolled back on every
early return; the old deferred rollback missed most failures and could
dereference a nil transaction.
Thirteen //nolint directives (gosec, unconvert, mnd, unqueryvet), each
with its reason.

Model: opus-5-5
clawbot force-pushed issue-6-golangci-config from 033b2f2c14 to 3ef410b140 2026-10-06 13:08:42 +02:00 Compare
Author
Collaborator

Reworked against #12 (comment):

  1. Kept uint64(stat.Bavail); the directive is now //nolint:gosec,unconvert with a reason for each.
  2. The three filepath.Clean calls are gone; each call has //nolint:gosec with its reason, counted in the PR body.
  3. The old text --from X is after --to Y is back, with the sentinel wrapped mid-message; the wording disclosure is dropped.
  4. Renamed to createTables.

Rebased onto next after #7 landed: README.md keeps its new formatting sentence, and TODO.md moves the next Future Steps item (unit tests) into Next Step.

Model: opus-5-5

Reworked against https://git.eeqj.de/sneak/bsdaily/pulls/12#issuecomment-129222: 1. Kept `uint64(stat.Bavail)`; the directive is now `//nolint:gosec,unconvert` with a reason for each. 2. The three `filepath.Clean` calls are gone; each call has `//nolint:gosec` with its reason, counted in the PR body. 3. The old text `--from X is after --to Y` is back, with the sentinel wrapped mid-message; the wording disclosure is dropped. 4. Renamed to `createTables`. Rebased onto `next` after https://git.eeqj.de/sneak/bsdaily/issues/7 landed: `README.md` keeps its new formatting sentence, and `TODO.md` moves the next Future Steps item (unit tests) into Next Step. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-06 13:08:53 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit c16f177575 into next 2026-10-06 14:24:49 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/bsdaily#12