fix: Address all errcheck and misspell linter errors

This commit is contained in:
Steve Yegge
2025-11-01 23:56:03 -07:00
parent a2361f85e7
commit 2b086951c4
15 changed files with 61 additions and 60 deletions

View File

@@ -56,7 +56,7 @@ func runEventDrivenLoop(
defer fallbackTicker.Stop()
} else {
watcher.Start(ctx, log)
defer watcher.Close()
defer func() { _ = watcher.Close() }()
}
// Handle mutation events from RPC server
@@ -124,10 +124,10 @@ func runEventDrivenLoop(
return
case <-ctx.Done():
log.log("Context canceled, shutting down")
if watcher != nil {
watcher.Close()
}
log.log("Context canceled, shutting down")
if watcher != nil {
_ = watcher.Close()
}
if err := server.Stop(); err != nil {
log.log("Error stopping server: %v", err)
}
@@ -137,7 +137,7 @@ func runEventDrivenLoop(
log.log("RPC server failed: %v", err)
cancel()
if watcher != nil {
watcher.Close()
_ = watcher.Close()
}
if stopErr := server.Stop(); stopErr != nil {
log.log("Error stopping server: %v", stopErr)

View File

@@ -87,7 +87,7 @@ func NewFileWatcher(jsonlPath string, onChanged func()) (*FileWatcher, error) {
// File doesn't exist yet - rely on parent dir watch
fmt.Fprintf(os.Stderr, "Info: JSONL file %s doesn't exist yet, watching parent directory\n", jsonlPath)
} else {
watcher.Close()
_ = watcher.Close()
if fallbackDisabled {
return nil, fmt.Errorf("failed to watch JSONL and BEADS_WATCHER_FALLBACK is disabled: %w", err)
}
@@ -148,8 +148,8 @@ func (fw *FileWatcher) Start(ctx context.Context, log daemonLogger) {
// Handle JSONL removal/rename (e.g., git checkout)
if event.Name == fw.jsonlPath && (event.Op&fsnotify.Remove != 0 || event.Op&fsnotify.Rename != 0) {
log.log("JSONL removed/renamed, re-establishing watch")
fw.watcher.Remove(fw.jsonlPath)
log.log("JSONL removed/renamed, re-establishing watch")
_ = fw.watcher.Remove(fw.jsonlPath)
// Retry with exponential backoff
fw.reEstablishWatch(ctx, log)
continue

View File

@@ -77,7 +77,7 @@ uptime, last activity, and exclusive lock status.`,
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "WORKSPACE\tPID\tVERSION\tUPTIME\tLAST ACTIVITY\tLOCK")
_, _ = fmt.Fprintln(w, "WORKSPACE\tPID\tVERSION\tUPTIME\tLAST ACTIVITY\tLOCK")
for _, d := range aliveDaemons {
workspace := d.WorkspacePath
@@ -99,11 +99,11 @@ uptime, last activity, and exclusive lock status.`,
lock = fmt.Sprintf("🔒 %s", d.ExclusiveLockHolder)
}
fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\n",
workspace, d.PID, d.Version, uptime, lastActivity, lock)
}
_, _ = fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\n",
workspace, d.PID, d.Version, uptime, lastActivity, lock)
}
w.Flush()
_ = w.Flush()
},
}
@@ -323,7 +323,7 @@ func tailFollow(filePath string) {
defer file.Close()
// Seek to end
file.Seek(0, io.SeekEnd)
_, _ = file.Seek(0, io.SeekEnd)
reader := bufio.NewReader(file)
for {
@@ -491,7 +491,7 @@ stale sockets, version mismatches, and unresponsive daemons.`,
fmt.Printf(" Unresponsive: %d\n\n", unresponsiveCount)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "WORKSPACE\tPID\tVERSION\tSTATUS\tISSUE")
_, _ = fmt.Fprintln(w, "WORKSPACE\tPID\tVERSION\tSTATUS\tISSUE")
for _, r := range reports {
workspace := r.Workspace
@@ -515,11 +515,11 @@ stale sockets, version mismatches, and unresponsive daemons.`,
issue = "-"
}
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
workspace, pidStr, version, status, issue)
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
workspace, pidStr, version, status, issue)
}
w.Flush()
_ = w.Flush()
// Exit with error if there are any issues
if staleCount > 0 || mismatchCount > 0 || unresponsiveCount > 0 {

View File

@@ -130,9 +130,9 @@ Example:
if !yes {
fmt.Printf("\nDelete %d test issues? [y/N] ", len(polluted))
var response string
fmt.Scanln(&response)
_, _ = fmt.Scanln(&response)
if strings.ToLower(response) != "y" {
fmt.Println("Cancelled.")
fmt.Println("Canceled.")
return
}
}

View File

@@ -438,10 +438,10 @@ func compareVersions(v1, v2 string) int {
// Get part value or default to 0 if part doesn't exist
if i < len(parts1) {
fmt.Sscanf(parts1[i], "%d", &p1)
_, _ = fmt.Sscanf(parts1[i], "%d", &p1)
}
if i < len(parts2) {
fmt.Sscanf(parts2[i], "%d", &p2)
_, _ = fmt.Sscanf(parts2[i], "%d", &p2)
}
if p1 < p2 {
@@ -474,7 +474,7 @@ func fetchLatestGitHubRelease() (string, error) {
if err != nil {
return "", err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("github api returned status %d", resp.StatusCode)

View File

@@ -256,9 +256,9 @@ This command:
}
fmt.Print("\nRemove these files? [y/N] ")
var response string
fmt.Scanln(&response)
_, _ = fmt.Scanln(&response)
if strings.ToLower(response) != "y" && strings.ToLower(response) != "yes" {
fmt.Println("Cleanup cancelled")
fmt.Println("Cleanup canceled")
return
}
}
@@ -302,8 +302,8 @@ This command:
ctx := context.Background()
issues, err := store.SearchIssues(ctx, "", types.IssueFilter{})
if err != nil {
store.Close()
if jsonOutput {
_ = store.Close()
if jsonOutput {
outputJSON(map[string]interface{}{
"error": "hash_migration_failed",
"message": err.Error(),
@@ -319,7 +319,7 @@ This command:
if !dryRun {
backupPath := strings.TrimSuffix(targetPath, ".db") + ".backup-pre-hash-" + time.Now().Format("20060102-150405") + ".db"
if err := copyFile(targetPath, backupPath); err != nil {
store.Close()
_ = store.Close()
if jsonOutput {
outputJSON(map[string]interface{}{
"error": "backup_failed",
@@ -333,10 +333,10 @@ This command:
if !jsonOutput {
color.Green("✓ Created backup: %s\n", filepath.Base(backupPath))
}
}
mapping, err := migrateToHashIDs(ctx, store, issues, dryRun)
store.Close()
}
mapping, err := migrateToHashIDs(ctx, store, issues, dryRun)
_ = store.Close()
if err != nil {
if jsonOutput {
@@ -355,10 +355,10 @@ This command:
fmt.Printf("\nWould migrate %d issues to hash-based IDs\n", len(mapping))
} else {
color.Green("✓ Migrated %d issues to hash-based IDs\n", len(mapping))
}
}
} else {
store.Close()
}
}
} else {
_ = store.Close()
if !jsonOutput {
fmt.Println("Database already uses hash-based IDs")
}
@@ -504,7 +504,7 @@ func handleUpdateRepoID(dryRun bool, autoYes bool) {
}
os.Exit(1)
}
defer store.Close()
defer func() { _ = store.Close() }()
// Get old repo ID
ctx := context.Background()
@@ -549,9 +549,9 @@ func handleUpdateRepoID(dryRun bool, autoYes bool) {
fmt.Printf("New repo ID: %s\n\n", newRepoID[:8])
fmt.Printf("Continue? [y/N] ")
var response string
fmt.Scanln(&response)
_, _ = fmt.Scanln(&response)
if strings.ToLower(response) != "y" && strings.ToLower(response) != "yes" {
fmt.Println("Cancelled")
fmt.Println("Canceled")
return
}
}

View File

@@ -85,7 +85,7 @@ Use --dry-run to preview changes before applying.`,
}
os.Exit(1)
}
defer store.Close()
defer func() { _ = store.Close() }()
// Get all issues using SearchIssues with empty query and no filters
issues, err := store.SearchIssues(ctx, "", types.IssueFilter{})

View File

@@ -125,7 +125,7 @@ Interactive mode with --interactive prompts for each orphan.`,
for _, o := range orphans {
fmt.Printf("Remove dependency %s → %s (%s)? [y/N]: ", o.issueID, o.dependsOnID, o.depType)
var response string
fmt.Scanln(&response)
_, _ = fmt.Scanln(&response)
if response == "y" || response == "Y" {
// Use direct SQL to remove orphaned dependencies
// RemoveDependency tries to mark the depends_on issue as dirty, which fails for orphans

View File

@@ -600,7 +600,7 @@ Examples:
os.Exit(1)
}
tmpPath := tmpFile.Name()
defer os.Remove(tmpPath)
defer func() { _ = os.Remove(tmpPath) }()
// Write current value to temp file
if _, err := tmpFile.WriteString(currentValue); err != nil {