Format Go with gofmt, then golines -m 77 (closes #215) #363

Merged
clawbot merged 1 commits from issue-215-golines into next 2026-11-11 17:29:13 +01:00
Collaborator

Adopts the Go formatting rule from sneak/prompts#160: gofmt, then golines -m 77. sneak ruled it on #215.

  • script/fmt runs golines -m 77 after gofmt. It repeats golines until it changes nothing, at most five times: one pass can leave a line that the next pass splits further, which would make make fmt-check fail straight after make fmt.
  • script/fmt-check fails when either tool would change a file.
  • script/bootstrap installs golines v0.13.0 with go install, pinned to its commit. It reads the installed version with go version -m.
  • Both scripts run the golines in GOBIN, or in GOPATH/bin when GOBIN is unset. They never use another copy on the PATH.

Most of the diff is golines output. These are the hand edits that keep lint green:

  • //nolint directives that golines moved off the flagged line now sit on their own line above the statement.
  • One string literal is split.
  • 20 functions went past funlen's 80 lines and are shortened or split:
    • in internal/sww/sww.go, RunWAF hands off to runWAFWithSettings, and a new cannotStart logs each startup error;
    • in internal/waf/biased.go, limitPercentages works out the limits shared by requests and bytes once;
    • five tests are split in two, and two failure messages in sww_test.go are shorter.

lll stays at 88, as in the vendored config.

Disclosure: the vendored REPO_POLICIES.md still names go fmt. Re-vendoring it brings in many unrelated changes, so it is left for the repo's next standards update.

Model: opus-5-5

Adopts the Go formatting rule from https://git.eeqj.de/sneak/prompts/issues/160: `gofmt`, then `golines -m 77`. sneak ruled it on https://git.eeqj.de/sneak/smallwebwaf/issues/215. - `script/fmt` runs `golines -m 77` after `gofmt`. It repeats `golines` until it changes nothing, at most five times: one pass can leave a line that the next pass splits further, which would make `make fmt-check` fail straight after `make fmt`. - `script/fmt-check` fails when either tool would change a file. - `script/bootstrap` installs `golines` v0.13.0 with `go install`, pinned to its commit. It reads the installed version with `go version -m`. - Both scripts run the `golines` in `GOBIN`, or in `GOPATH/bin` when `GOBIN` is unset. They never use another copy on the `PATH`. Most of the diff is `golines` output. These are the hand edits that keep lint green: - `//nolint` directives that `golines` moved off the flagged line now sit on their own line above the statement. - One string literal is split. - 20 functions went past `funlen`'s 80 lines and are shortened or split: - in `internal/sww/sww.go`, `RunWAF` hands off to `runWAFWithSettings`, and a new `cannotStart` logs each startup error; - in `internal/waf/biased.go`, `limitPercentages` works out the limits shared by requests and bytes once; - five tests are split in two, and two failure messages in `sww_test.go` are shorter. `lll` stays at 88, as in the vendored config. Disclosure: the vendored `REPO_POLICIES.md` still names `go fmt`. Re-vendoring it brings in many unrelated changes, so it is left for the repo's next standards update. Model: opus-5-5
clawbot added the needs-review label 2026-11-11 15:53:24 +01:00
clawbot self-assigned this 2026-11-11 15:53:24 +01:00
Author
Collaborator

Verdict: FAIL
Head: a8b24a843b

  1. The branch conflicts with next (needs-rebase). next now splits internal/config/config.go into config.go, waf.go and rproxy.go (one settings file per daemon, #227). Acceptable: rebase onto next, run make fmt again so the moved and new code is formatted too, redo the hand fixes that code needs (the //nolint:gosec above os.ReadFile(path), any new funlen overrun), and make check passes.
  2. script/fmt, line 46: the golines -m 77 -l call is the while condition, where set -e does not apply. When golines fails (a crash, a binary that will not run), the loop ends at once and make fmt exits 0 without having formatted anything with it. Acceptable: inside the loop, assign that list to a variable on its own line and break when it is empty, as script/fmt-check already does, so a golines failure fails make fmt.

Model: opus-5-5

Verdict: FAIL Head: a8b24a843b6c09281238d1d71fb038104495b99b 1. The branch conflicts with `next` (`needs-rebase`). `next` now splits `internal/config/config.go` into `config.go`, `waf.go` and `rproxy.go` (one settings file per daemon, https://git.eeqj.de/sneak/smallwebwaf/issues/227). Acceptable: rebase onto `next`, run `make fmt` again so the moved and new code is formatted too, redo the hand fixes that code needs (the `//nolint:gosec` above `os.ReadFile(path)`, any new `funlen` overrun), and `make check` passes. 2. `script/fmt`, line 46: the `golines -m 77 -l` call is the `while` condition, where `set -e` does not apply. When `golines` fails (a crash, a binary that will not run), the loop ends at once and `make fmt` exits 0 without having formatted anything with it. Acceptable: inside the loop, assign that list to a variable on its own line and break when it is empty, as `script/fmt-check` already does, so a `golines` failure fails `make fmt`. Model: opus-5-5
clawbot added the needs-rebase label 2026-11-11 16:03:09 +01:00
clawbot removed the needs-rebase label 2026-11-11 16:09:57 +01:00
clawbot added 1 commit 2026-11-11 16:15:10 +01:00
script/fmt now runs golines -m 77 after gofmt, repeating golines until
it changes nothing, since one pass can leave a line the next splits.
script/fmt-check fails when either would change a file.
script/bootstrap installs golines v0.13.0 with go install, pinned to
its commit, and checks the installed version with go version -m.

The tree is reformatted. The longer lines this makes are fixed by
hand: nolint directives moved onto their own line above the statement,
one string split, and 20 functions over funlen's 80 lines shortened or
split, RunWAF and limitPercentages among them.

Model: opus-5-5
clawbot force-pushed issue-215-golines from a8b24a843b to 7f8a59de04 2026-11-11 16:15:10 +01:00 Compare
Author
Collaborator
  1. Rebased onto next (head 7f8a59d). make fmt ran again over config.go, waf.go and rproxy.go, and //nolint:gosec sits above os.ReadFile(path) in config.go again. The moved code caused no new funlen overrun.
  2. script/fmt now assigns the golines -l list to a variable inside the loop and breaks when it is empty. A golines failure now fails make fmt.

Model: opus-5-5

1. Rebased onto `next` (head `7f8a59d`). `make fmt` ran again over `config.go`, `waf.go` and `rproxy.go`, and `//nolint:gosec` sits above `os.ReadFile(path)` in `config.go` again. The moved code caused no new `funlen` overrun. 2. `script/fmt` now assigns the `golines -l` list to a variable inside the loop and breaks when it is empty. A `golines` failure now fails `make fmt`. Model: opus-5-5
Author
Collaborator

Verdict: PASS
Head: 7f8a59de04

Meets the formatting ruling on #215, and the hand edits leave behaviour and test cases unchanged.

  • Judgement call: the scripts run the golines in GOBIN or GOPATH/bin, where the prompts policy text reads the copy on the PATH. I accepted this, since only the pinned build runs.
  • Judgement call: I accepted the vendored REPO_POLICIES.md still naming go fmt until the repo's next standards update, as the PR body discloses.

Model: opus-5-5

Verdict: PASS Head: 7f8a59de04ddadf48b61bd3b06b6a426dee834a4 Meets the formatting ruling on https://git.eeqj.de/sneak/smallwebwaf/issues/215, and the hand edits leave behaviour and test cases unchanged. - Judgement call: the scripts run the `golines` in `GOBIN` or `GOPATH/bin`, where the prompts policy text reads the copy on the `PATH`. I accepted this, since only the pinned build runs. - Judgement call: I accepted the vendored `REPO_POLICIES.md` still naming `go fmt` until the repo's next standards update, as the PR body discloses. Model: opus-5-5
Author
Collaborator

script/cibuild fails on this PR merged onto next. Last 40 lines:

#26 23.60 Building dependency tree...
#26 23.61 Reading state information...
#26 23.61 E: Unable to locate package nix-bin
#26 23.61 E: Unable to locate package runit
#26 ERROR: process "/bin/sh -c echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man     && apt-get update     && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends         ca-certificates nix-bin runit     && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man     && find /usr/share/man/man1 ! -type d -delete     && find /etc/alternatives -type l -xtype l -delete" did not complete successfully: exit code: 100

#25 [lint 6/6] RUN golangci-lint run --config .golangci.yml --build-tags recorded ./...
#25 CANCELED

#28 [test-recorded 1/1] RUN --mount=type=tmpfs,target=/root/.cache/go-build     go test -tags no_fs_access,recorded -timeout 90s -cover         -skip '^TestConcurrent' ./internal/coreruleset ||     { echo "--- Rerunning with -v for details ---";       go test -tags no_fs_access,recorded -timeout 90s -v         -skip '^TestConcurrent' ./internal/coreruleset;       exit 1; }
#28 CANCELED

#22 [test-race 1/1] RUN --mount=type=tmpfs,target=/root/.cache/go-build     others="$(go list ./... | grep -vxF sneak.berlin/go/smallwebwaf/internal/coreruleset)";     { go test -tags no_fs_access -timeout 90s -race -cover $others &&       go test -tags no_fs_access -timeout 90s -race -cover         -run '^TestConcurrent' ./internal/coreruleset; } ||     { echo "--- Rerunning with -v for details ---";       go test -tags no_fs_access -timeout 90s -race -v $others;       go test -tags no_fs_access -timeout 90s -race -v         -run '^TestConcurrent' ./internal/coreruleset;       exit 1; }
#22 CANCELED
------
 > [stage-9  3/11] RUN echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man     && apt-get update     && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends         ca-certificates nix-bin runit     && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man     && find /usr/share/man/man1 ! -type d -delete     && find /etc/alternatives -type l -xtype l -delete:
23.36   Could not resolve 'archive.ubuntu.com'
23.36 Err:7 http://archive.ubuntu.com/ubuntu resolute-updates InRelease
23.36   Could not resolve 'archive.ubuntu.com'
23.36 Err:6 http://archive.ubuntu.com/ubuntu resolute InRelease
23.36   Could not resolve 'archive.ubuntu.com'

23.60 Building dependency tree...
23.61 Reading state information...
23.61 E: Unable to locate package nix-bin
23.61 E: Unable to locate package runit
------
Dockerfile:182
--------------------
 181 |     # so no man page or package is added.
 182 | >>> RUN echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man \
 183 | >>>     && apt-get update \
 184 | >>>     && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
 185 | >>>         ca-certificates nix-bin runit \
 186 | >>>     && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man \
 187 | >>>     && find /usr/share/man/man1 ! -type d -delete \
 188 | >>>     && find /etc/alternatives -type l -xtype l -delete
 189 |     
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man     && apt-get update     && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends         ca-certificates nix-bin runit     && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man     && find /usr/share/man/man1 ! -type d -delete     && find /etc/alternatives -type l -xtype l -delete" did not complete successfully: exit code: 100

Model: opus-5-5

`script/cibuild` fails on this PR merged onto `next`. Last 40 lines: ```` #26 23.60 Building dependency tree... #26 23.61 Reading state information... #26 23.61 E: Unable to locate package nix-bin #26 23.61 E: Unable to locate package runit #26 ERROR: process "/bin/sh -c echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends ca-certificates nix-bin runit && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man && find /usr/share/man/man1 ! -type d -delete && find /etc/alternatives -type l -xtype l -delete" did not complete successfully: exit code: 100 #25 [lint 6/6] RUN golangci-lint run --config .golangci.yml --build-tags recorded ./... #25 CANCELED #28 [test-recorded 1/1] RUN --mount=type=tmpfs,target=/root/.cache/go-build go test -tags no_fs_access,recorded -timeout 90s -cover -skip '^TestConcurrent' ./internal/coreruleset || { echo "--- Rerunning with -v for details ---"; go test -tags no_fs_access,recorded -timeout 90s -v -skip '^TestConcurrent' ./internal/coreruleset; exit 1; } #28 CANCELED #22 [test-race 1/1] RUN --mount=type=tmpfs,target=/root/.cache/go-build others="$(go list ./... | grep -vxF sneak.berlin/go/smallwebwaf/internal/coreruleset)"; { go test -tags no_fs_access -timeout 90s -race -cover $others && go test -tags no_fs_access -timeout 90s -race -cover -run '^TestConcurrent' ./internal/coreruleset; } || { echo "--- Rerunning with -v for details ---"; go test -tags no_fs_access -timeout 90s -race -v $others; go test -tags no_fs_access -timeout 90s -race -v -run '^TestConcurrent' ./internal/coreruleset; exit 1; } #22 CANCELED ------ > [stage-9 3/11] RUN echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends ca-certificates nix-bin runit && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man && find /usr/share/man/man1 ! -type d -delete && find /etc/alternatives -type l -xtype l -delete: 23.36 Could not resolve 'archive.ubuntu.com' 23.36 Err:7 http://archive.ubuntu.com/ubuntu resolute-updates InRelease 23.36 Could not resolve 'archive.ubuntu.com' 23.36 Err:6 http://archive.ubuntu.com/ubuntu resolute InRelease 23.36 Could not resolve 'archive.ubuntu.com' 23.60 Building dependency tree... 23.61 Reading state information... 23.61 E: Unable to locate package nix-bin 23.61 E: Unable to locate package runit ------ Dockerfile:182 -------------------- 181 | # so no man page or package is added. 182 | >>> RUN echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man \ 183 | >>> && apt-get update \ 184 | >>> && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \ 185 | >>> ca-certificates nix-bin runit \ 186 | >>> && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man \ 187 | >>> && find /usr/share/man/man1 ! -type d -delete \ 188 | >>> && find /etc/alternatives -type l -xtype l -delete 189 | -------------------- ERROR: failed to build: failed to solve: process "/bin/sh -c echo 'path-include=/usr/share/man/man1/*' > /etc/dpkg/dpkg.cfg.d/z-man && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends ca-certificates nix-bin runit && rm -rf /var/lib/apt/lists/* /etc/dpkg/dpkg.cfg.d/z-man && find /usr/share/man/man1 ! -type d -delete && find /etc/alternatives -type l -xtype l -delete" did not complete successfully: exit code: 100 ```` Model: opus-5-5
clawbot added the needs-checks label 2026-11-11 16:42:14 +01:00
clawbot removed the needs-checks label 2026-11-11 16:55:02 +01:00
Author
Collaborator

archive.ubuntu.com did not resolve inside the Docker build: a DNS failure on the build machine, not this PR, which changes no Dockerfile. Nothing to change or rebase; the merge can be retried on head 7f8a59d.

Model: opus-5-5

`archive.ubuntu.com` did not resolve inside the Docker build: a DNS failure on the build machine, not this PR, which changes no `Dockerfile`. Nothing to change or rebase; the merge can be retried on head `7f8a59d`. Model: opus-5-5
Author
Collaborator

The failure was a DNS outage on the build host (archive.ubuntu.com did not resolve), not this change. The label is reset so the merge is retried on the same head.

Model: opus-5-5

The failure was a DNS outage on the build host (`archive.ubuntu.com` did not resolve), not this change. The label is reset so the merge is retried on the same head. Model: opus-5-5
clawbot merged commit 0b23352767 into next 2026-11-11 17:29:13 +01:00
Sign in to join this conversation.