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:
@@ -260,7 +260,7 @@ func (t *Tmux) GetSessionInfo(name string) (*SessionInfo, error) {
|
||||
}
|
||||
|
||||
windows := 0
|
||||
fmt.Sscanf(parts[1], "%d", &windows)
|
||||
_, _ = fmt.Sscanf(parts[1], "%d", &windows)
|
||||
|
||||
return &SessionInfo{
|
||||
Name: parts[0],
|
||||
|
||||
@@ -50,13 +50,13 @@ func TestSessionLifecycle(t *testing.T) {
|
||||
sessionName := "gt-test-session-" + t.Name()
|
||||
|
||||
// Clean up any existing session
|
||||
tm.KillSession(sessionName)
|
||||
_ = tm.KillSession(sessionName)
|
||||
|
||||
// Create session
|
||||
if err := tm.NewSession(sessionName, ""); err != nil {
|
||||
t.Fatalf("NewSession: %v", err)
|
||||
}
|
||||
defer tm.KillSession(sessionName)
|
||||
defer func() { _ = tm.KillSession(sessionName) }()
|
||||
|
||||
// Verify exists
|
||||
has, err := tm.HasSession(sessionName)
|
||||
@@ -107,13 +107,13 @@ func TestDuplicateSession(t *testing.T) {
|
||||
sessionName := "gt-test-dup-" + t.Name()
|
||||
|
||||
// Clean up any existing session
|
||||
tm.KillSession(sessionName)
|
||||
_ = tm.KillSession(sessionName)
|
||||
|
||||
// Create session
|
||||
if err := tm.NewSession(sessionName, ""); err != nil {
|
||||
t.Fatalf("NewSession: %v", err)
|
||||
}
|
||||
defer tm.KillSession(sessionName)
|
||||
defer func() { _ = tm.KillSession(sessionName) }()
|
||||
|
||||
// Try to create duplicate
|
||||
err := tm.NewSession(sessionName, "")
|
||||
@@ -131,13 +131,13 @@ func TestSendKeysAndCapture(t *testing.T) {
|
||||
sessionName := "gt-test-keys-" + t.Name()
|
||||
|
||||
// Clean up any existing session
|
||||
tm.KillSession(sessionName)
|
||||
_ = tm.KillSession(sessionName)
|
||||
|
||||
// Create session
|
||||
if err := tm.NewSession(sessionName, ""); err != nil {
|
||||
t.Fatalf("NewSession: %v", err)
|
||||
}
|
||||
defer tm.KillSession(sessionName)
|
||||
defer func() { _ = tm.KillSession(sessionName) }()
|
||||
|
||||
// Send echo command
|
||||
if err := tm.SendKeys(sessionName, "echo HELLO_TEST_MARKER"); err != nil {
|
||||
@@ -167,13 +167,13 @@ func TestGetSessionInfo(t *testing.T) {
|
||||
sessionName := "gt-test-info-" + t.Name()
|
||||
|
||||
// Clean up any existing session
|
||||
tm.KillSession(sessionName)
|
||||
_ = tm.KillSession(sessionName)
|
||||
|
||||
// Create session
|
||||
if err := tm.NewSession(sessionName, ""); err != nil {
|
||||
t.Fatalf("NewSession: %v", err)
|
||||
}
|
||||
defer tm.KillSession(sessionName)
|
||||
defer func() { _ = tm.KillSession(sessionName) }()
|
||||
|
||||
info, err := tm.GetSessionInfo(sessionName)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user