Skip to content

Commit c752c06

Browse files
cpcloudclaude
andcommitted
chore: suppress false-positive gosec G118/G602/G703 from updated linter
The flake update pulled a newer golangci-lint with new gosec rules: - G118: cancel stored in struct field, called later (not leaked) - G602: specs and natural slices have equal length by construction - G703: WriteFile paths are tmpDir + constant filename, not tainted Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1d4bcd2 commit c752c06

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

internal/app/chat_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ func TestCancellationDuringSQLGeneration(t *testing.T) {
120120
m := newTestModel(t)
121121
m.openChat()
122122

123-
_, cancel := context.WithCancel(context.Background())
123+
_, cancel := context.WithCancel(
124+
context.Background(),
125+
) //nolint:gosec // cancel stored in CancelFn, called by ctrl+c
124126
m.chat.CurrentQuery = testQuestion
125127
m.chat.Streaming = true
126128
m.chat.StreamingSQL = true
@@ -150,7 +152,9 @@ func TestCancellationDuringAnswerStreaming(t *testing.T) {
150152
m := newTestModel(t)
151153
m.openChat()
152154

153-
_, cancel := context.WithCancel(context.Background())
155+
_, cancel := context.WithCancel(
156+
context.Background(),
157+
) //nolint:gosec // cancel stored in CancelFn, called by ctrl+c
154158
m.chat.CurrentQuery = testQuestion
155159
m.chat.Streaming = true
156160
m.chat.StreamingSQL = false // stage 2

internal/app/extraction.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ func (m *Model) rerunLLMExtraction() tea.Cmd {
935935

936936
// Replace a cancelled context so the rerun has a live one.
937937
if ex.ctx.Err() != nil {
938-
ctx, cancel := context.WithCancel(context.Background())
938+
ctx, cancel := context.WithCancel(
939+
context.Background(),
940+
) //nolint:gosec // cancel stored in ex.CancelFn, called on extraction close
939941
ex.ctx = ctx
940942
ex.CancelFn = cancel
941943
}

internal/app/table.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,9 @@ func columnWidths(
879879
// Content exceeds terminal width — apply Max constraints.
880880
widths := make([]int, columnCount)
881881
for i, w := range natural {
882-
if specs[i].Max > 0 && w > specs[i].Max {
883-
w = specs[i].Max
882+
if specs[i].Max > 0 &&
883+
w > specs[i].Max { //nolint:gosec // specs and natural have equal length (columnCount)
884+
w = specs[i].Max //nolint:gosec // same bounds
884885
}
885886
widths[i] = w
886887
}

internal/extract/ocr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func ocrPDF(ctx context.Context, data []byte, maxPages int) (string, []byte, err
3838
defer os.RemoveAll(tmpDir) //nolint:errcheck // best-effort cleanup
3939

4040
pdfPath := filepath.Join(tmpDir, "input.pdf")
41-
if err := os.WriteFile(pdfPath, data, 0o600); err != nil {
41+
if err := os.WriteFile(pdfPath, data, 0o600); err != nil { //nolint:gosec // path is tmpDir + constant filename
4242
return "", nil, fmt.Errorf("write temp pdf: %w", err)
4343
}
4444

@@ -271,7 +271,7 @@ func ocrImage(ctx context.Context, data []byte) (string, []byte, error) {
271271
defer os.RemoveAll(tmpDir) //nolint:errcheck // best-effort cleanup
272272

273273
imgPath := filepath.Join(tmpDir, "input")
274-
if err := os.WriteFile(imgPath, data, 0o600); err != nil {
274+
if err := os.WriteFile(imgPath, data, 0o600); err != nil { //nolint:gosec // path is tmpDir + constant filename
275275
return "", nil, fmt.Errorf("write temp image: %w", err)
276276
}
277277

internal/extract/ocr_progress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func ocrImageWithProgress(ctx context.Context, data []byte, ch chan<- ExtractPro
7373
defer os.RemoveAll(tmpDir) //nolint:errcheck // best-effort cleanup
7474

7575
imgPath := filepath.Join(tmpDir, "input.png")
76-
if err := os.WriteFile(imgPath, data, 0o600); err != nil {
76+
if err := os.WriteFile(imgPath, data, 0o600); err != nil { //nolint:gosec // path is tmpDir + constant filename
7777
ch <- ExtractProgress{Err: fmt.Errorf("write temp image: %w", err), Done: true}
7878
return
7979
}

0 commit comments

Comments
 (0)