-
Notifications
You must be signed in to change notification settings - Fork 325
Closed as not planned
Labels
bugSomething isn't workingSomething isn't workingstaleNo recent activity has been detected on this issue/PR and it will be closedNo recent activity has been detected on this issue/PR and it will be closed
Description
Severity: LOW (Code Quality Issue)
Bug Summary
The cancel channel field in StatusSpinner is never initialized or used. It exists but serves no purpose, representing dead code that should be removed.
Location
- File: pkg/statushooks/spinner.go
- Field: StatusSpinner.cancel (line 28)
- Usage: Only referenced in Hide() (lines 96-98) but always nil
Evidence
type StatusSpinner struct {
spinner *spinner.Spinner
cancel chan struct{} // Never initialized - always nil
delay time.Duration
visible bool
}
func (s *StatusSpinner) Hide() {
s.visible = false
if s.cancel != nil { // This is always false
close(s.cancel)
}
s.closeSpinner()
}The cancel channel is:
- Declared but never initialized (always nil)
- Never created with
make(chan struct{}) - Never read from or used for cancellation
- The check
if s.cancel != nilis always false
Reproduction
func TestSpinnerCancelChannelNeverInitialized(t *testing.T) {
spinner := NewStatusSpinnerHook()
if spinner.cancel != nil {
t.Error("Cancel channel should be nil (it's never initialized)")
}
spinner.Show()
spinner.Hide()
// cancel is still nil - never used
}Impact
- Code Quality: Dead code adds confusion
- Maintenance: Developers may think cancel is used for something
- No Runtime Impact: Since it's never used, no functional impact
Proposed Fix
Remove the unused field and related code:
type StatusSpinner struct {
spinner *spinner.Spinner
// Remove: cancel chan struct{}
delay time.Duration
visible bool
}
func (s *StatusSpinner) Hide() {
s.visible = false
// Remove: if s.cancel != nil { close(s.cancel) }
s.closeSpinner()
}Found by: Wave 3 Task 1 (Statushooks)
Test: TestSpinnerCancelChannelNeverInitialized in pkg/statushooks/statushooks_test.go
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstaleNo recent activity has been detected on this issue/PR and it will be closedNo recent activity has been detected on this issue/PR and it will be closed