Verify Go formatting with gofumpt, not gofmt, so fmt and check agree #70

Open
opened 2026-08-09 03:40:50 +02:00 by clawbot · 0 comments
Collaborator

Context

script/fmt:20 writes with gofumpt -l -w mfer internal cmd.

script/fmt-check and script/lint both verify with plain gofmt -l ..

gofumpt is a strict superset of gofmt, so a file can be gofmt-clean
while still being rewritten by gofumpt. The result is that make lint,
make fmt-check, and therefore make check can all pass green on a tree
that make fmt would immediately modify. The gate does not check what the
formatter enforces.

There is a second, quieter mismatch: script/fmt formats only the
mfer internal cmd directories, while the check commands run over .
(everything). The two commands do not even operate on the same file set.

Definition of done

  • script/fmt-check and script/lint verify with gofumpt -l, matching
    what script/fmt writes.
  • script/fmt and script/fmt-check operate on the same file set. Pick one
    — either both take the explicit directory list or both take . — and make
    them consistent.
  • Round-trip holds: on a clean tree, make fmt produces no diff and
    make fmt-check passes; after deliberately introducing a gofumpt-only
    violation (one that gofmt accepts), make fmt-check fails and make fmt
    fixes it.
  • Generated files (mfer/mf.pb.go) are excluded from the check, or verified
    to already satisfy it, so the gate does not fail on code the repo does not
    author.
  • make check passes. TODO.md updated in the same commit.

Implementation requirements

  • gofumpt must be installed by script/bootstrap; that is tracked in #68.
    Until it is, script/fmt-check must fail with a clear "run make bootstrap"
    message rather than silently passing when gofumpt is absent. A check that
    no-ops when its tool is missing is the bug this issue is about.
  • Do not switch script/fmt down to gofmt to resolve the mismatch in the
    other direction. gofumpt is the intended formatter; the checks are what
    is wrong.
  • Check whether .golangci.yml already enables a gofumpt formatter pass.
    If golangci-lint is already enforcing it, the standalone check may be
    redundant — say so explicitly in the commit message rather than leaving
    two overlapping mechanisms with no comment. Do not modify .golangci.yml
    either way; it is user-owned.
  • Commit title must end with (closes #70).
## Context `script/fmt:20` writes with `gofumpt -l -w mfer internal cmd`. `script/fmt-check` and `script/lint` both verify with plain `gofmt -l .`. `gofumpt` is a strict superset of `gofmt`, so a file can be `gofmt`-clean while still being rewritten by `gofumpt`. The result is that `make lint`, `make fmt-check`, and therefore `make check` can all pass green on a tree that `make fmt` would immediately modify. The gate does not check what the formatter enforces. There is a second, quieter mismatch: `script/fmt` formats only the `mfer internal cmd` directories, while the check commands run over `.` (everything). The two commands do not even operate on the same file set. ## Definition of done - `script/fmt-check` and `script/lint` verify with `gofumpt -l`, matching what `script/fmt` writes. - `script/fmt` and `script/fmt-check` operate on the same file set. Pick one — either both take the explicit directory list or both take `.` — and make them consistent. - Round-trip holds: on a clean tree, `make fmt` produces no diff and `make fmt-check` passes; after deliberately introducing a gofumpt-only violation (one that `gofmt` accepts), `make fmt-check` fails and `make fmt` fixes it. - Generated files (`mfer/mf.pb.go`) are excluded from the check, or verified to already satisfy it, so the gate does not fail on code the repo does not author. - `make check` passes. `TODO.md` updated in the same commit. ## Implementation requirements - `gofumpt` must be installed by `script/bootstrap`; that is tracked in #68. Until it is, `script/fmt-check` must fail with a clear "run make bootstrap" message rather than silently passing when `gofumpt` is absent. A check that no-ops when its tool is missing is the bug this issue is about. - Do not switch `script/fmt` down to `gofmt` to resolve the mismatch in the other direction. `gofumpt` is the intended formatter; the checks are what is wrong. - Check whether `.golangci.yml` already enables a `gofumpt` formatter pass. If `golangci-lint` is already enforcing it, the standalone check may be redundant — say so explicitly in the commit message rather than leaving two overlapping mechanisms with no comment. Do not modify `.golangci.yml` either way; it is user-owned. - Commit title must end with ` (closes #70)`.
clawbot added this to the 1.0.0 milestone 2026-08-09 03:40:50 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/mfer#70