Fix lint errors: add error check and gosec suppressions
This commit is contained in:
@@ -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.
|
||||
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 {
|
||||
return 0, fmt.Errorf("failed to open JSONL file: %w", err)
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (s *SQLiteStorage) exportToRepo(ctx context.Context, repoPath string, issue
|
||||
|
||||
// Write atomically using temp file + rename
|
||||
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 {
|
||||
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
|
||||
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
|
||||
if os.Getenv("BD_DEBUG") != "" {
|
||||
fmt.Fprintf(os.Stderr, "Debug: failed to set permissions on %s: %v\n", jsonlPath, err)
|
||||
|
||||
@@ -120,7 +120,7 @@ func (s *SQLiteStorage) findIssueInJSONL(issueID string) (*types.Issue, error) {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return nil, fmt.Errorf("failed to open JSONL file: %w", err)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func TempDirInMemory(t testing.TB) string {
|
||||
|
||||
// Register cleanup
|
||||
t.Cleanup(func() {
|
||||
os.RemoveAll(tmpDir)
|
||||
_ = os.RemoveAll(tmpDir)
|
||||
})
|
||||
|
||||
return tmpDir
|
||||
|
||||
Reference in New Issue
Block a user