Format Go with gofmt, then golines -m 77 (closes #215)
check / check (push) Waiting to run

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
This commit is contained in:
sneak committed 2026-11-11 15:14:58 +00:00
1 parent 63e58e326b
commit 7f8a59de04
118 files changed
+9447 -2670

No files matched your search

+80 -24
View File
@@ -92,8 +92,10 @@ func TestLogLineHasEachFieldWhereItApplies(t *testing.T) {
}
if strings.Contains(out.text(), "secret") {
t.Errorf("a value of Authorization, Cookie or Set-Cookie is logged:\n%s",
out.text())
t.Errorf(
"a value of Authorization, Cookie or Set-Cookie is logged:\n%s",
out.text(),
)
}
}
@@ -102,7 +104,10 @@ func TestLogLineHasEachFieldWhereItApplies(t *testing.T) {
func wantFullLine(t *testing.T, line logLine) {
t.Helper()
headers := map[string]string{"accept": "text/html", "x-custom": "one, two"}
headers := map[string]string{
"accept": "text/html",
"x-custom": "one, two",
}
want := withTimings(line, requestlog.Line{
Type: requestType, WAFLine: requestlog.WAFLineReport,
@@ -120,8 +125,13 @@ func wantFullLine(t *testing.T, line logLine) {
Minute: 1, Hour: 1, Day: 1, MinuteBytes: 8, HourBytes: 8, DayBytes: 8,
},
})
if !reflect.DeepEqual(line.Line, want) || line.RequestID == "from-traefik" {
t.Errorf("log line\n%+v\nwant\n%+v, with a new request id", line.Line, want)
if !reflect.DeepEqual(line.Line, want) ||
line.RequestID == "from-traefik" {
t.Errorf(
"log line\n%+v\nwant\n%+v, with a new request id",
line.Line,
want,
)
}
}
@@ -140,7 +150,11 @@ func wantBareLine(t *testing.T, line logLine) {
Action: requestlog.ActionForward,
})
if !reflect.DeepEqual(line.Line, want) || line.RequestID == "" {
t.Errorf("log line\n%+v\nwant\n%+v, with a request id", line.Line, want)
t.Errorf(
"log line\n%+v\nwant\n%+v, with a request id",
line.Line,
want,
)
}
for _, name := range []string{
@@ -163,7 +177,9 @@ func withTimings(line logLine, want requestlog.Line) requestlog.Line {
return want
}
func TestHasAuthorizationAndHasCookieEachComeFromTheirOwnHeader(t *testing.T) {
func TestHasAuthorizationAndHasCookieEachComeFromTheirOwnHeader(
t *testing.T,
) {
t.Parallel()
const hasAuthorization, hasCookie = "has_authorization", "has_cookie"
@@ -186,8 +202,13 @@ func TestHasAuthorizationAndHasCookieEachComeFromTheirOwnHeader(t *testing.T) {
_, otherPresent := line.fields[tc.other]
if line.fields[tc.field] != true || otherPresent {
t.Errorf("log line has %s %v and %s %v, want true and none",
tc.field, line.fields[tc.field], tc.other, line.fields[tc.other])
t.Errorf(
"log line has %s %v and %s %v, want true and none",
tc.field,
line.fields[tc.field],
tc.other,
line.fields[tc.other],
)
}
})
}
@@ -206,10 +227,16 @@ func TestTimingsAreInOrder(t *testing.T) {
_, _ = io.WriteString(w, "done")
})
addr, out, server := startProxyWithClock(t, app.URL, "", time.Now, map[string]string{
trustedProxies: trustLocalhost,
denyNets: denied,
})
addr, out, server := startProxyWithClock(
t,
app.URL,
"",
time.Now,
map[string]string{
trustedProxies: trustLocalhost,
denyNets: denied,
},
)
// Each log line is waited for before the next request, so that the
// lines are in order.
@@ -243,8 +270,12 @@ func TestTimingsAreInOrder(t *testing.T) {
// The checks end before the request is handed to the app.
if checks+upstream > total {
t.Errorf("timings in microseconds: total %d, checks %d, upstream total %d",
total, checks, upstream)
t.Errorf(
"timings in microseconds: total %d, checks %d, upstream total %d",
total,
checks,
upstream,
)
}
if *refused.DurationChecksMS > refused.DurationTotalMS {
@@ -269,7 +300,12 @@ func wantTimings(t *testing.T, line logLine, want ...string) {
slices.Sort(want)
if !slices.Equal(got, want) {
t.Errorf("log line of %s has timings %v, want %v", line.Path, got, want)
t.Errorf(
"log line of %s has timings %v, want %v",
line.Path,
got,
want,
)
}
}
@@ -280,23 +316,43 @@ func wantHeuristic(t *testing.T, line logLine, heuristic, figures string) {
t.Helper()
if line.Heuristic != heuristic ||
!reflect.DeepEqual(line.HeuristicFigures, decodeFigures(t, figures)) {
t.Errorf("log line has heuristic %q with heuristic_figures %v, want %q with %s",
line.Heuristic, line.HeuristicFigures, heuristic, figures)
!reflect.DeepEqual(
line.HeuristicFigures,
decodeFigures(t, figures),
) {
t.Errorf(
"log line has heuristic %q with heuristic_figures %v, want %q with %s",
line.Heuristic,
line.HeuristicFigures,
heuristic,
figures,
)
}
}
// wantAfterAnswerHeuristic checks after_answer_heuristic and
// after_answer_heuristic_figures as wantHeuristic checks heuristic and
// heuristic_figures.
func wantAfterAnswerHeuristic(t *testing.T, line logLine, heuristic, figures string) {
func wantAfterAnswerHeuristic(
t *testing.T,
line logLine,
heuristic, figures string,
) {
t.Helper()
if line.AfterAnswerHeuristic != heuristic ||
!reflect.DeepEqual(line.AfterAnswerHeuristicFigures, decodeFigures(t, figures)) {
t.Errorf("log line has after_answer_heuristic %q with "+
"after_answer_heuristic_figures %v, want %q with %s",
line.AfterAnswerHeuristic, line.AfterAnswerHeuristicFigures, heuristic, figures)
!reflect.DeepEqual(
line.AfterAnswerHeuristicFigures,
decodeFigures(t, figures),
) {
t.Errorf(
"log line has after_answer_heuristic %q with "+
"after_answer_heuristic_figures %v, want %q with %s",
line.AfterAnswerHeuristic,
line.AfterAnswerHeuristicFigures,
heuristic,
figures,
)
}
}