Fix lint errors: add error check and gosec suppressions

This commit is contained in:
Steve Yegge
2025-11-05 01:11:09 -08:00
parent 97786e0bf9
commit 52cf2af9f7
4 changed files with 5 additions and 5 deletions

View File

@@ -118,7 +118,7 @@ func (s *SQLiteStorage) hydrateFromRepo(ctx context.Context, repoPath, sourceRep
// importJSONLFile imports issues from a JSONL file, setting the source_repo field. // importJSONLFile imports issues from a JSONL file, setting the source_repo field.
func (s *SQLiteStorage) importJSONLFile(ctx context.Context, jsonlPath, sourceRepo string) (int, error) { func (s *SQLiteStorage) importJSONLFile(ctx context.Context, jsonlPath, sourceRepo string) (int, error) {
file, err := os.Open(jsonlPath) file, err := os.Open(jsonlPath) // #nosec G304 -- jsonlPath is from trusted source
if err != nil { if err != nil {
return 0, fmt.Errorf("failed to open JSONL file: %w", err) return 0, fmt.Errorf("failed to open JSONL file: %w", err)
} }

View File

@@ -127,7 +127,7 @@ func (s *SQLiteStorage) exportToRepo(ctx context.Context, repoPath string, issue
// Write atomically using temp file + rename // Write atomically using temp file + rename
tempPath := fmt.Sprintf("%s.tmp.%d", jsonlPath, os.Getpid()) tempPath := fmt.Sprintf("%s.tmp.%d", jsonlPath, os.Getpid())
f, err := os.Create(tempPath) f, err := os.Create(tempPath) // #nosec G304 -- tempPath derived from trusted jsonlPath
if err != nil { if err != nil {
return 0, fmt.Errorf("failed to create temp file: %w", err) return 0, fmt.Errorf("failed to create temp file: %w", err)
} }
@@ -161,7 +161,7 @@ func (s *SQLiteStorage) exportToRepo(ctx context.Context, repoPath string, issue
} }
// Set file permissions // Set file permissions
if err := os.Chmod(jsonlPath, 0644); err != nil { if err := os.Chmod(jsonlPath, 0644); err != nil { // nolint:gosec // G302: 0644 intentional for git-tracked files
// Non-fatal // Non-fatal
if os.Getenv("BD_DEBUG") != "" { if os.Getenv("BD_DEBUG") != "" {
fmt.Fprintf(os.Stderr, "Debug: failed to set permissions on %s: %v\n", jsonlPath, err) fmt.Fprintf(os.Stderr, "Debug: failed to set permissions on %s: %v\n", jsonlPath, err)

View File

@@ -120,7 +120,7 @@ func (s *SQLiteStorage) findIssueInJSONL(issueID string) (*types.Issue, error) {
} }
// Open and scan JSONL file // Open and scan JSONL file
file, err := os.Open(jsonlPath) file, err := os.Open(jsonlPath) // #nosec G304 -- jsonlPath is from trusted beads directory
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open JSONL file: %w", err) return nil, fmt.Errorf("failed to open JSONL file: %w", err)
} }

View File

@@ -55,7 +55,7 @@ func TempDirInMemory(t testing.TB) string {
// Register cleanup // Register cleanup
t.Cleanup(func() { t.Cleanup(func() {
os.RemoveAll(tmpDir) _ = os.RemoveAll(tmpDir)
}) })
return tmpDir return tmpDir