From c8d98a052982baaa0f3ee0d3ce41a6e97226c6f5 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sat, 9 May 2026 01:44:49 -0700 Subject: [PATCH] fix(lint): remaining errcheck in fork.go and fork_test.go Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/cmd/fork.go | 12 ++++++------ internal/cmd/fork_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/cmd/fork.go b/internal/cmd/fork.go index 9de08d9..8052867 100644 --- a/internal/cmd/fork.go +++ b/internal/cmd/fork.go @@ -134,8 +134,8 @@ func forkSession(srcPath, dstPath, newSessionID, targetDir string) (*forkResult, var record map[string]any if err := json.Unmarshal([]byte(line), &record); err != nil { - writer.WriteString(line) - writer.WriteByte('\n') + _, _ = writer.WriteString(line) + _ = writer.WriteByte('\n') lineCount++ continue } @@ -160,14 +160,14 @@ func forkSession(srcPath, dstPath, newSessionID, targetDir string) (*forkResult, rewritten, err := json.Marshal(record) if err != nil { - writer.WriteString(line) - writer.WriteByte('\n') + _, _ = writer.WriteString(line) + _ = writer.WriteByte('\n') lineCount++ continue } - writer.Write(rewritten) - writer.WriteByte('\n') + _, _ = writer.Write(rewritten) + _ = writer.WriteByte('\n') lineCount++ } diff --git a/internal/cmd/fork_test.go b/internal/cmd/fork_test.go index d917649..67467c9 100644 --- a/internal/cmd/fork_test.go +++ b/internal/cmd/fork_test.go @@ -62,7 +62,7 @@ func TestForkRewritesSessionIDAndCWD(t *testing.T) { scanner := bufio.NewScanner(f) for scanner.Scan() { var record map[string]any - json.Unmarshal([]byte(scanner.Text()), &record) + _ = json.Unmarshal([]byte(scanner.Text()), &record) if sid, ok := record["sessionId"].(string); ok { if sid != "new-session-id" { @@ -92,7 +92,7 @@ func TestForkDropsFileHistorySnapshot(t *testing.T) { `{"type":"user","sessionId":"old","cwd":"/old","uuid":"u1","message":{"role":"user","content":"hi"}}`, `{"type":"file-history-snapshot","messageId":"m2","snapshot":{},"isSnapshotUpdate":true}`, } - os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644) + _ = os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644) result, err := forkSession(srcPath, dstPath, "new-id", "/new") if err != nil { @@ -117,7 +117,7 @@ func TestForkNullsWorktreeState(t *testing.T) { `{"type":"user","sessionId":"old","cwd":"/old","uuid":"u1","message":{"role":"user","content":"hi"}}`, `{"type":"worktree-state","worktreeSession":{"worktreePath":"/old/worktree"},"worktreePath":"/old/worktree"}`, } - os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644) + _ = os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644) _, err := forkSession(srcPath, dstPath, "new-id", "/new") if err != nil { @@ -129,7 +129,7 @@ func TestForkNullsWorktreeState(t *testing.T) { scanner := bufio.NewScanner(f) for scanner.Scan() { var record map[string]any - json.Unmarshal([]byte(scanner.Text()), &record) + _ = json.Unmarshal([]byte(scanner.Text()), &record) if record["type"] == "worktree-state" { if record["worktreeSession"] != nil { t.Error("worktreeSession should be null in forked output") @@ -151,9 +151,9 @@ func TestForkPreservesParentUUIDChain(t *testing.T) { `{"type":"assistant","sessionId":"old","cwd":"/old","uuid":"a1","parentUuid":"u1","message":{"role":"assistant","content":"a"}}`, `{"type":"user","sessionId":"old","cwd":"/old","uuid":"u2","parentUuid":"a1","message":{"role":"user","content":"q2"}}`, } - os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644) + _ = os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644) - forkSession(srcPath, dstPath, "new-id", "/new") + _, _ = forkSession(srcPath, dstPath, "new-id", "/new") f, _ := os.Open(dstPath) defer f.Close()