From e3fb19fa1b2478b91647d55750816392b0f5976a Mon Sep 17 00:00:00 2001 From: Rodin Date: Thu, 14 May 2026 22:53:59 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20dev-loop=20cleanup=20=E2=80=94=20go=20?= =?UTF-8?q?fmt=20and=20go=20mod=20tidy=20at=202026-05-14=2022:53=20UTC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- budget/budget_test.go | 1 - cmd/review-bot/main.go | 2 -- cmd/review-bot/main_test.go | 5 ++--- gitea/client_test.go | 1 + gitea/ipcheck_test.go | 10 +++++----- github/client.go | 6 +++--- llm/client.go | 10 +++++----- llm/client_test.go | 1 - review/persona_test.go | 2 +- review/prompt_test.go | 1 - review/repo_persona_test.go | 14 +++++++------- 11 files changed, 24 insertions(+), 29 deletions(-) diff --git a/budget/budget_test.go b/budget/budget_test.go index 7efc917..966b834 100644 --- a/budget/budget_test.go +++ b/budget/budget_test.go @@ -157,7 +157,6 @@ func TestFit_PreservesNoteInOutput(t *testing.T) { } } - func TestFit_HugeUserMeta(t *testing.T) { // UserMeta so large that base alone exceeds limit // Use a unique marker past the truncation point diff --git a/cmd/review-bot/main.go b/cmd/review-bot/main.go index 1771f94..55d479e 100644 --- a/cmd/review-bot/main.go +++ b/cmd/review-bot/main.go @@ -901,5 +901,3 @@ func shouldSkipStaleReview(evaluatedSHA, currentSHA string) bool { } return evaluatedSHA != currentSHA } - - diff --git a/cmd/review-bot/main_test.go b/cmd/review-bot/main_test.go index 7511c47..e4a2ec3 100644 --- a/cmd/review-bot/main_test.go +++ b/cmd/review-bot/main_test.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strings" "testing" - ) func TestValidateReviewerName(t *testing.T) { @@ -820,8 +819,8 @@ func TestExtractSentinelName_EdgeCases(t *testing.T) { {" rest", "sonnet"}, {" rest", "gpt-review"}, {"no sentinel here", "unknown"}, - {" end", "abc"}, // embedded in text + {" end", "abc"}, // embedded in text } for _, tc := range tests { diff --git a/gitea/client_test.go b/gitea/client_test.go index 8de33ab..c35a474 100644 --- a/gitea/client_test.go +++ b/gitea/client_test.go @@ -971,6 +971,7 @@ func TestDoGet_RespectsContextCancellation(t *testing.T) { t.Errorf("attempts = %d, expected 1 before context cancel during backoff", attempts) } } + // mockTransport is a test helper that returns errors for the first N calls, // then delegates to a real server. type mockTransport struct { diff --git a/gitea/ipcheck_test.go b/gitea/ipcheck_test.go index 0d3d08e..b9903e6 100644 --- a/gitea/ipcheck_test.go +++ b/gitea/ipcheck_test.go @@ -69,11 +69,11 @@ func TestIsBlockedIP(t *testing.T) { {"public 8.8.8.8", "8.8.8.8"}, {"public 1.1.1.1", "1.1.1.1"}, {"public 198.51.100.1", "198.51.100.1"}, // RFC5737 TEST-NET-2 — a documentation-only range; - // not assigned to any real host, but intentionally left unblocked here because - // it has no special routing treatment (unlike RFC1918/loopback/link-local) and - // blocking it would require tracking every RFC5737 range without meaningful - // security benefit (no server should ever listen on a TEST-NET address). - {"public 151.101.1.1", "151.101.1.1"}, // Fastly + // not assigned to any real host, but intentionally left unblocked here because + // it has no special routing treatment (unlike RFC1918/loopback/link-local) and + // blocking it would require tracking every RFC5737 range without meaningful + // security benefit (no server should ever listen on a TEST-NET address). + {"public 151.101.1.1", "151.101.1.1"}, // Fastly {"public IPv6 2001:4860:4860::8888", "2001:4860:4860::8888"}, // Google DNS {"public IPv6 2606:4700:4700::1111", "2606:4700:4700::1111"}, // Cloudflare DNS } diff --git a/github/client.go b/github/client.go index d77aa8c..bdd6408 100644 --- a/github/client.go +++ b/github/client.go @@ -463,9 +463,9 @@ type ChangedFile struct { type ReviewComment struct { ID int64 `json:"id,omitempty"` Path string `json:"path"` - Position int64 `json:"position,omitempty"` // GitHub diff hunk position - Line int64 `json:"line,omitempty"` // GitHub absolute line number (alternative to position) - Side string `json:"side,omitempty"` // "RIGHT" or "LEFT" + Position int64 `json:"position,omitempty"` // GitHub diff hunk position + Line int64 `json:"line,omitempty"` // GitHub absolute line number (alternative to position) + Side string `json:"side,omitempty"` // "RIGHT" or "LEFT" Body string `json:"body"` } diff --git a/llm/client.go b/llm/client.go index 074db52..b9adaed 100644 --- a/llm/client.go +++ b/llm/client.go @@ -207,11 +207,11 @@ func (c *Client) completeOpenAI(ctx context.Context, messages []Message) (string type anthropicRequest struct { AnthropicVersion string `json:"anthropic_version,omitempty"` - Model string `json:"model,omitempty"` - MaxTokens int `json:"max_tokens"` - System string `json:"system,omitempty"` - Messages []anthropicMsg `json:"messages"` - Temperature float64 `json:"temperature,omitempty"` + Model string `json:"model,omitempty"` + MaxTokens int `json:"max_tokens"` + System string `json:"system,omitempty"` + Messages []anthropicMsg `json:"messages"` + Temperature float64 `json:"temperature,omitempty"` } type anthropicMsg struct { diff --git a/llm/client_test.go b/llm/client_test.go index c7713af..093cb57 100644 --- a/llm/client_test.go +++ b/llm/client_test.go @@ -210,7 +210,6 @@ func TestWithTimeout(t *testing.T) { } } - func TestComplete_Anthropic_Success(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/messages" { diff --git a/review/persona_test.go b/review/persona_test.go index c23698f..9a24ae5 100644 --- a/review/persona_test.go +++ b/review/persona_test.go @@ -355,7 +355,7 @@ func TestCapitalizeFirst(t *testing.T) { {"HELLO", "HELLO"}, {"a", "A"}, {"", ""}, - {"日本語", "日本語"}, // Non-ASCII: Japanese doesn't have case + {"日本語", "日本語"}, // Non-ASCII: Japanese doesn't have case {"über", "Über"}, // German umlaut {"élève", "Élève"}, // French accent } diff --git a/review/prompt_test.go b/review/prompt_test.go index b8d705e..f9a02a0 100644 --- a/review/prompt_test.go +++ b/review/prompt_test.go @@ -117,7 +117,6 @@ func TestBuildUserPrompt_WithoutFileContext(t *testing.T) { } } - func TestBuildSystemBase(t *testing.T) { result := BuildSystemBase() if result == "" { diff --git a/review/repo_persona_test.go b/review/repo_persona_test.go index 56b0a59..0e49400 100644 --- a/review/repo_persona_test.go +++ b/review/repo_persona_test.go @@ -9,11 +9,11 @@ import ( func TestParsePersonaBytes(t *testing.T) { tests := []struct { - name string - data string - source string - wantName string - wantErr string + name string + data string + source string + wantName string + wantErr string }{ { name: "valid yaml", @@ -38,8 +38,8 @@ focus: wantErr: "parse", }, { - name: "json format by extension", - data: `{"name": "jsontest", "identity": "json identity"}`, + name: "json format by extension", + data: `{"name": "jsontest", "identity": "json identity"}`, source: "test.json", wantName: "jsontest", },