Skip to content

Commit 4e4c532

Browse files
committed
fix lint issues
1 parent f8941db commit 4e4c532

File tree

6 files changed

+20
-32
lines changed

6 files changed

+20
-32
lines changed

cmd/goose/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ func TestNotificationScenarios(t *testing.T) {
644644
t.Errorf("%s: Expected PR to be tracked as blocked", tt.description)
645645
}
646646
// Should have set FirstBlockedAt in state manager
647-
if state, exists := app.stateManager.GetPRState("https://github.com/test/repo/pull/1"); !exists || state.FirstBlockedAt.IsZero() {
647+
if state, exists := app.stateManager.PRState("https://github.com/test/repo/pull/1"); !exists || state.FirstBlockedAt.IsZero() {
648648
t.Errorf("%s: Expected FirstBlockedAt to be set in state manager", tt.description)
649649
}
650650
}
@@ -699,7 +699,7 @@ func TestNewlyBlockedPRAfterGracePeriod(t *testing.T) {
699699
}
700700

701701
// Verify FirstBlockedAt was set in state manager
702-
if state, exists := app.stateManager.GetPRState("https://github.com/test/repo/pull/1"); !exists || state.FirstBlockedAt.IsZero() {
702+
if state, exists := app.stateManager.PRState("https://github.com/test/repo/pull/1"); !exists || state.FirstBlockedAt.IsZero() {
703703
t.Error("Expected FirstBlockedAt to be set for newly blocked PR in state manager")
704704
}
705705
}

cmd/goose/notifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (app *App) processNotifications(ctx context.Context) {
3333
app.mu.Lock()
3434
app.previousBlockedPRs = make(map[string]bool)
3535
app.blockedPRTimes = make(map[string]time.Time)
36-
states := app.stateManager.GetBlockedPRs()
36+
states := app.stateManager.BlockedPRs()
3737
for url, state := range states {
3838
app.previousBlockedPRs[url] = true
3939
app.blockedPRTimes[url] = state.FirstBlockedAt

cmd/goose/pr_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func (m *PRStateManager) UpdatePRs(incoming, outgoing []PR, hiddenOrgs map[strin
120120
return toNotify
121121
}
122122

123-
// GetBlockedPRs returns all currently blocked PRs with their states.
124-
func (m *PRStateManager) GetBlockedPRs() map[string]*PRState {
123+
// BlockedPRs returns all currently blocked PRs with their states.
124+
func (m *PRStateManager) BlockedPRs() map[string]*PRState {
125125
m.mu.RLock()
126126
defer m.mu.RUnlock()
127127

@@ -132,8 +132,8 @@ func (m *PRStateManager) GetBlockedPRs() map[string]*PRState {
132132
return result
133133
}
134134

135-
// GetPRState returns the state for a specific PR.
136-
func (m *PRStateManager) GetPRState(url string) (*PRState, bool) {
135+
// PRState returns the state for a specific PR.
136+
func (m *PRStateManager) PRState(url string) (*PRState, bool) {
137137
m.mu.RLock()
138138
defer m.mu.RUnlock()
139139

cmd/goose/pr_state_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestPRStateManager(t *testing.T) {
3636
}
3737

3838
// Verify state was removed
39-
if _, exists := mgr.GetPRState(pr1.URL); exists {
39+
if _, exists := mgr.PRState(pr1.URL); exists {
4040
t.Error("Expected PR state to be removed when unblocked")
4141
}
4242

@@ -66,7 +66,7 @@ func TestPRStateManagerGracePeriod(t *testing.T) {
6666
}
6767

6868
// Verify state is still tracked
69-
if _, exists := mgr.GetPRState(pr1.URL); !exists {
69+
if _, exists := mgr.PRState(pr1.URL); !exists {
7070
t.Error("Expected PR state to be tracked even during grace period")
7171
}
7272

cmd/goose/systray_interface.go

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package main
22

33
import (
4-
"reflect"
5-
64
"github.com/energye/systray"
75
)
86

97
// SystrayInterface abstracts systray operations for testing.
108
type SystrayInterface interface {
119
ResetMenu()
12-
AddMenuItem(title, tooltip string) *systray.MenuItem
10+
AddMenuItem(title, tooltip string) MenuItem
1311
AddSeparator()
1412
SetTitle(title string)
1513
SetOnClick(fn func(menu systray.IMenu))
@@ -23,8 +21,9 @@ func (*RealSystray) ResetMenu() {
2321
systray.ResetMenu()
2422
}
2523

26-
func (*RealSystray) AddMenuItem(title, tooltip string) *systray.MenuItem {
27-
return systray.AddMenuItem(title, tooltip)
24+
func (*RealSystray) AddMenuItem(title, tooltip string) MenuItem {
25+
item := systray.AddMenuItem(title, tooltip)
26+
return &RealMenuItem{MenuItem: item}
2827
}
2928

3029
func (*RealSystray) AddSeparator() {
@@ -53,24 +52,13 @@ func (m *MockSystray) ResetMenu() {
5352
m.menuItems = nil
5453
}
5554

56-
func (m *MockSystray) AddMenuItem(title, _ string) *systray.MenuItem {
55+
func (m *MockSystray) AddMenuItem(title, tooltip string) MenuItem {
5756
m.menuItems = append(m.menuItems, title)
58-
// Create a MenuItem with initialized internal maps using reflection
59-
// This prevents nil map panics when methods are called
60-
item := &systray.MenuItem{}
61-
62-
// Use reflection to initialize internal maps if they exist
63-
// This is a hack but necessary for testing
64-
rv := reflect.ValueOf(item).Elem()
65-
rt := rv.Type()
66-
for i := 0; i < rt.NumField(); i++ {
67-
field := rv.Field(i)
68-
if field.Kind() == reflect.Map && field.IsNil() && field.CanSet() {
69-
field.Set(reflect.MakeMap(field.Type()))
70-
}
57+
// Return a MockMenuItem that won't panic when methods are called
58+
return &MockMenuItem{
59+
title: title,
60+
tooltip: tooltip,
7161
}
72-
73-
return item
7462
}
7563

7664
func (m *MockSystray) AddSeparator() {

cmd/goose/ui.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (app *App) addPRSection(ctx context.Context, prs []PR, sectionTitle string,
217217
// Add bullet point or emoji for blocked PRs
218218
if sortedPRs[prIndex].NeedsReview || sortedPRs[prIndex].IsBlocked {
219219
// Get the blocked time from state manager
220-
prState, hasState := app.stateManager.GetPRState(sortedPRs[prIndex].URL)
220+
prState, hasState := app.stateManager.PRState(sortedPRs[prIndex].URL)
221221

222222
// Show emoji for PRs blocked within the last 5 minutes
223223
if hasState && !prState.FirstBlockedAt.IsZero() && time.Since(prState.FirstBlockedAt) < blockedPRIconDuration {
@@ -369,7 +369,7 @@ func (app *App) generatePRSectionTitles(prs []PR, sectionTitle string, hiddenOrg
369369

370370
// Add bullet point or emoji for blocked PRs (same logic as in addPRSection)
371371
if sortedPRs[prIndex].NeedsReview || sortedPRs[prIndex].IsBlocked {
372-
prState, hasState := app.stateManager.GetPRState(sortedPRs[prIndex].URL)
372+
prState, hasState := app.stateManager.PRState(sortedPRs[prIndex].URL)
373373

374374
if hasState && !prState.FirstBlockedAt.IsZero() && time.Since(prState.FirstBlockedAt) < blockedPRIconDuration {
375375
if sectionTitle == "Outgoing" {

0 commit comments

Comments
 (0)