From 378ac59f418b787be6ed85b715520de0a2634adb Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Fri, 16 Oct 2026 14:43:37 +0100 Subject: [PATCH] Fixed some lint and code convention violations --- cmd/mock-fts/main_test.go | 5 ++++- internal/cli/config/csrf_key_test.go | 4 +++- internal/cli/ws/dial_test.go | 7 +++++-- internal/cli/ws/direct.go | 4 +++- internal/cli/ws/direct_test.go | 20 +++++++++++++++----- internal/logging/accesslog_test.go | 4 +++- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/cmd/mock-fts/main_test.go b/cmd/mock-fts/main_test.go index 24e167b..8994389 100644 --- a/cmd/mock-fts/main_test.go +++ b/cmd/mock-fts/main_test.go @@ -19,7 +19,10 @@ func TestBaseURLFromAddr(t *testing.T) { for _, tt := range tests { got, err := baseURLFromAddr(tt.addr) if err != nil || got != tt.want { - t.Errorf("baseURLFromAddr(%q) = %q, %v; want %q", tt.addr, got, err, tt.want) + t.Errorf( + "baseURLFromAddr(%q) = %q, %v; want %q", + tt.addr, got, err, tt.want, + ) } } } diff --git a/internal/cli/config/csrf_key_test.go b/internal/cli/config/csrf_key_test.go index 02926cb..433fc30 100644 --- a/internal/cli/config/csrf_key_test.go +++ b/internal/cli/config/csrf_key_test.go @@ -69,7 +69,9 @@ func TestGenerateCSRFKeyPrint(t *testing.T) { key := strings.TrimSpace(mustRun(t, "config", "generate-csrf-key", "--print")) checkCSRFKey(t, key) - other := strings.TrimSpace(mustRun(t, "config", "generate-csrf-key", "--print")) + other := strings.TrimSpace( + mustRun(t, "config", "generate-csrf-key", "--print"), + ) if other == key { t.Error("two keys were the same") } diff --git a/internal/cli/ws/dial_test.go b/internal/cli/ws/dial_test.go index 6c4c99e..fa67c5d 100644 --- a/internal/cli/ws/dial_test.go +++ b/internal/cli/ws/dial_test.go @@ -76,7 +76,9 @@ func TestDialPingFlag(t *testing.T) { cmdtest.Setup(t, "") _, url := wsServer(t) - out := cmdtest.MustRun(t, newRoot, "dial", "--http-upgrade", "--url", url, "--ping") + out := cmdtest.MustRun( + t, newRoot, "dial", "--http-upgrade", "--url", url, "--ping", + ) cmdtest.Contains( t, out, @@ -302,7 +304,8 @@ func TestDialStdinError(t *testing.T) { select { case err := <-done: - if err == nil || !strings.Contains(err.Error(), "reading input: disk on fire") { + if err == nil || + !strings.Contains(err.Error(), "reading input: disk on fire") { t.Fatalf("dial = %v; want the input error", err) } case <-time.After(time.Second): diff --git a/internal/cli/ws/direct.go b/internal/cli/ws/direct.go index c4b3c94..76d430a 100644 --- a/internal/cli/ws/direct.go +++ b/internal/cli/ws/direct.go @@ -48,7 +48,9 @@ func dialDirect(ctx context.Context, addr string) (*directConn, error) { // Read returns the next line as a text message, skipping the blank lines the // server sends to check the connection. Cancelling ctx interrupts it. The // server closing the connection is reported as io.EOF. -func (d *directConn) Read(ctx context.Context) (websocket.MessageType, []byte, error) { +func (d *directConn) Read( + ctx context.Context, +) (websocket.MessageType, []byte, error) { stop := context.AfterFunc(ctx, func() { d.conn.SetReadDeadline(time.Now()) //nolint:errcheck,gosec // only interrupts the read }) diff --git a/internal/cli/ws/direct_test.go b/internal/cli/ws/direct_test.go index ce745fc..33127d7 100644 --- a/internal/cli/ws/direct_test.go +++ b/internal/cli/ws/direct_test.go @@ -180,7 +180,8 @@ func TestDialModeFlags(t *testing.T) { {"upgrade with addr", []string{"--http-upgrade", "--addr", "h:1"}, "none of the others"}, } for _, tt := range tests { - _, err := cmdtest.Run(t, newRoot, "", append([]string{"dial"}, tt.args...)...) + args := append([]string{"dial"}, tt.args...) + _, err := cmdtest.Run(t, newRoot, "", args...) if err == nil { t.Errorf("%s: dial was accepted", tt.name) continue @@ -214,16 +215,25 @@ func TestDirectConn(t *testing.T) { // Without --addr, --direct uses the configured host and port. func TestDefaultAddr(t *testing.T) { tests := []struct { + name string conf config.JSCServer want string }{ - {config.JSCServer{Host: "10.0.0.1", Port: 8080}, "10.0.0.1:8080"}, - {config.JSCServer{Port: 9393}, "127.0.0.1:9393"}, - {config.JSCServer{Host: "::1", Port: 9393}, "[::1]:9393"}, + {"configured", config.JSCServer{ + Host: "10.0.0.1", + Port: 8080, + }, "10.0.0.1:8080"}, + {"every interface", config.JSCServer{ + Port: 9393, + }, "127.0.0.1:9393"}, + {"IPv6", config.JSCServer{ + Host: "::1", + Port: 9393, + }, "[::1]:9393"}, } for _, tt := range tests { if got := defaultAddr(tt.conf); got != tt.want { - t.Errorf("defaultAddr(%+v) = %q; want %q", tt.conf, got, tt.want) + t.Errorf("%s: defaultAddr = %q; want %q", tt.name, got, tt.want) } } } diff --git a/internal/logging/accesslog_test.go b/internal/logging/accesslog_test.go index 65a77aa..bc13939 100644 --- a/internal/logging/accesslog_test.go +++ b/internal/logging/accesslog_test.go @@ -172,7 +172,9 @@ func TestAccessLogHijack(t *testing.T) { readWriter.WriteString("HTTP/1.1 204 No Content\r\n\r\n") readWriter.Flush() }) - server := httptest.NewServer(AccessLog(log.New(&buffer, "", 0), true, handler)) + server := httptest.NewServer( + AccessLog(log.New(&buffer, "", 0), true, handler), + ) defer server.Close() res, err := http.Get(server.URL + "/hijacked")