fix(lint): resolve all errcheck warnings

Fix ~50 errcheck warnings across the codebase:

- Add explicit `_ =` for intentionally ignored error returns (cleanup,
  best-effort operations, etc.)
- Use `defer func() { _ = ... }()` pattern for defer statements
- Handle tmux SetEnvironment, KillSession, SendKeysRaw returns
- Handle mail router.Send returns
- Handle os.RemoveAll, os.Rename in cleanup paths
- Handle rand.Read returns for ID generation
- Handle fmt.Fprint* returns when writing to io.Writer
- Fix for-select with single case to use for-range
- Handle cobra MarkFlagRequired returns

All tests pass. Code compiles without errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-19 12:09:52 -08:00
parent 3a477f673c
commit 4048cdc373
29 changed files with 115 additions and 125 deletions

View File

@@ -93,7 +93,7 @@ func (m *Mailbox) listBeads() ([]*Message, error) {
var beadsMsgs []BeadsMessage
if err := json.Unmarshal(stdout.Bytes(), &beadsMsgs); err != nil {
// Empty inbox returns empty array or nothing
if len(stdout.Bytes()) == 0 || string(stdout.Bytes()) == "null" {
if len(stdout.Bytes()) == 0 || stdout.String() == "null" {
return nil, nil
}
return nil, err
@@ -116,7 +116,7 @@ func (m *Mailbox) listLegacy() ([]*Message, error) {
}
return nil, err
}
defer file.Close()
defer func() { _ = file.Close() }()
var messages []*Message
scanner := bufio.NewScanner(file)
@@ -336,7 +336,7 @@ func (m *Mailbox) appendLegacy(msg *Message) error {
if err != nil {
return err
}
defer file.Close()
defer func() { _ = file.Close() }()
data, err := json.Marshal(msg)
if err != nil {
@@ -364,15 +364,15 @@ func (m *Mailbox) rewriteLegacy(messages []*Message) error {
for _, msg := range messages {
data, err := json.Marshal(msg)
if err != nil {
file.Close()
os.Remove(tmpPath)
_ = file.Close()
_ = os.Remove(tmpPath)
return err
}
file.WriteString(string(data) + "\n")
_, _ = file.WriteString(string(data) + "\n")
}
if err := file.Close(); err != nil {
os.Remove(tmpPath)
_ = os.Remove(tmpPath)
return err
}
@@ -408,7 +408,7 @@ func (m *Mailbox) listByThreadBeads(threadID string) ([]*Message, error) {
var beadsMsgs []BeadsMessage
if err := json.Unmarshal(stdout.Bytes(), &beadsMsgs); err != nil {
if len(stdout.Bytes()) == 0 || string(stdout.Bytes()) == "null" {
if len(stdout.Bytes()) == 0 || stdout.String() == "null" {
return nil, nil
}
return nil, err

View File

@@ -72,7 +72,7 @@ func (r *Router) Send(msg *Message) error {
}
// Notify recipient if they have an active session
r.notifyRecipient(msg)
_ = r.notifyRecipient(msg)
return nil
}

View File

@@ -114,14 +114,14 @@ func NewReplyMessage(from, to, subject, body string, original *Message) *Message
// generateID creates a random message ID.
func generateID() string {
b := make([]byte, 8)
rand.Read(b)
_, _ = rand.Read(b)
return "msg-" + hex.EncodeToString(b)
}
// generateThreadID creates a random thread ID.
func generateThreadID() string {
b := make([]byte, 6)
rand.Read(b)
_, _ = rand.Read(b)
return "thread-" + hex.EncodeToString(b)
}