Skip to content

Polish codebase: fix panics, check errors, reduce duplication#235

Merged
drn merged 1 commit intomasterfrom
worktree-argus/polish
Mar 15, 2026
Merged

Polish codebase: fix panics, check errors, reduce duplication#235
drn merged 1 commit intomasterfrom
worktree-argus/polish

Conversation

@drn
Copy link
Owner

@drn drn commented Mar 15, 2026

Clean code analysis and refactoring across 31 files:

  • Add bounds checking to prevent panics on unexpected system command output
  • Check ignored errors from json.Unmarshal, os.WriteFile, cobra Execute()
  • Extract shared utilities: pkg/jsonutil.Print, pkg/run.CaptureClean
  • Unify component registry into single source of truth
  • Consolidate duplicate code in link, spotify auth, and slack packages
  • Replace os.Exit in cache.Log with bool return for testability
  • Remove unused types, fix byte-vs-rune slicing, use const where appropriate

Co-Authored-By: Claude noreply@anthropic.com

- Add bounds checking in battery-percent, cpu, tmux-status/right,
  openweather, and wttr to prevent panics on unexpected input
- Check ignored errors from json.Unmarshal, os.WriteFile, cfg.SaveTo,
  and cobra Execute() across gmail, slack, tts, and config packages
- Extract shared printJSON to pkg/jsonutil, duplicate capture() to
  pkg/run.CaptureClean, and consolidate link.Soft/Hard into shared helper
- Unify component registry: single source of truth in install.Components()
  eliminates duplicate lists in install.go and install/root.go
- Consolidate spotify token exchange and extract API URL constants
- Replace os.Exit(0) in cache.Log with bool return for testability
- Remove unused Color/Separator types, fix byte-vs-rune slicing in ssid
- Move git-ancestor package-level vars into main(), use const

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@drn drn merged commit 5c206b2 into master Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant