Skip to content

Commit 04bf3e9

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
lint
1 parent 3f1988d commit 04bf3e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+421
-524
lines changed

cmd/server/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,6 @@ func (cm *coordinatorManager) handleRefreshInstallations(ctx context.Context) {
671671
// runBotCoordinators manages bot coordinators for all GitHub installations.
672672
// It spawns one coordinator per org and refreshes the list every 5 minutes.
673673
// Failed coordinators are automatically restarted every minute.
674-
//
675-
//nolint:interfacebloat // Interface mirrors state.Store for local type safety
676674
func runBotCoordinators(
677675
ctx context.Context,
678676
slackManager *slack.Manager,

pkg/bot/bot.go

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ type prContext struct {
3737
Number int
3838
}
3939

40-
// ThreadInfo is an alias to cache.ThreadInfo for backward compatibility.
41-
type ThreadInfo = cache.ThreadInfo
42-
43-
// ThreadCache is an alias to cache.ThreadCache for backward compatibility.
44-
type ThreadCache = cache.ThreadCache
45-
46-
// CommitPRCache is an alias to cache.CommitPRCache for backward compatibility.
47-
type CommitPRCache = cache.CommitPRCache
48-
4940
// Coordinator coordinates between GitHub, Slack, and notifications for a single org.
5041
//
5142
//nolint:govet // Field order optimized for logical grouping over memory alignment
@@ -59,15 +50,15 @@ type Coordinator struct {
5950
configManager ConfigManager
6051
notifier *notify.Manager
6152
userMapper UserMapper
62-
threadCache *ThreadCache // In-memory cache for fast lookups
63-
commitPRCache *CommitPRCache // Maps commit SHAs to PR numbers for check events
64-
eventSemaphore chan struct{} // Limits concurrent event processing (prevents overwhelming APIs)
53+
threadCache *cache.ThreadCache // In-memory cache for fast lookups
54+
commitPRCache *cache.CommitPRCache // Maps commit SHAs to PR numbers for check events
55+
eventSemaphore chan struct{} // Limits concurrent event processing (prevents overwhelming APIs)
6556
}
6657

6758
// StateStore interface for persistent state - allows dependency injection for testing.
6859
type StateStore interface {
69-
Thread(owner, repo string, number int, channelID string) (ThreadInfo, bool)
70-
SaveThread(owner, repo string, number int, channelID string, info ThreadInfo) error
60+
Thread(owner, repo string, number int, channelID string) (cache.ThreadInfo, bool)
61+
SaveThread(owner, repo string, number int, channelID string, info cache.ThreadInfo) error
7162
LastDM(userID, prURL string) (time.Time, bool)
7263
RecordDM(userID, prURL string, sentAt time.Time) error
7364
ListDMUsers(prURL string) []string
@@ -127,7 +118,7 @@ func New(
127118

128119
// saveThread persists thread info to both cache and persistent storage.
129120
// This ensures threads survive restarts and are available for closed PR updates.
130-
func (c *Coordinator) saveThread(owner, repo string, number int, channelID string, info ThreadInfo) {
121+
func (c *Coordinator) saveThread(owner, repo string, number int, channelID string, info cache.ThreadInfo) {
131122
// Save to in-memory cache for fast lookups
132123
key := fmt.Sprintf("%s/%s#%d:%s", owner, repo, number, channelID)
133124
c.threadCache.Set(key, info)
@@ -205,7 +196,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
205196
"current_message_preview", initialSearchText[:min(100, len(initialSearchText))])
206197

207198
// Save the found thread (cache + persist)
208-
c.saveThread(owner, repo, prNumber, channelID, ThreadInfo{
199+
c.saveThread(owner, repo, prNumber, channelID, cache.ThreadInfo{
209200
ThreadTS: initialSearchTS,
210201
ChannelID: channelID,
211202
LastState: prState,
@@ -248,7 +239,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
248239
// Try to take over creation
249240
if !c.threadCache.MarkCreating(cacheKey) {
250241
// Still being created, give up
251-
return "", false, "", fmt.Errorf("timed out waiting for thread creation")
242+
return "", false, "", errors.New("timed out waiting for thread creation")
252243
}
253244
}
254245
}
@@ -281,7 +272,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
281272
"note", "this prevented duplicate thread creation during rolling deployment")
282273

283274
// Save it and return (cache + persist)
284-
c.saveThread(owner, repo, prNumber, channelID, ThreadInfo{
275+
c.saveThread(owner, repo, prNumber, channelID, cache.ThreadInfo{
285276
ThreadTS: crossInstanceCheckTS,
286277
ChannelID: channelID,
287278
LastState: prState,
@@ -304,7 +295,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
304295
}
305296

306297
// Save the new thread (cache + persist)
307-
c.saveThread(owner, repo, prNumber, channelID, ThreadInfo{
298+
c.saveThread(owner, repo, prNumber, channelID, cache.ThreadInfo{
308299
ThreadTS: newThreadTS,
309300
ChannelID: channelID,
310301
LastState: prState,
@@ -1394,7 +1385,7 @@ func (c *Coordinator) processPRForChannel(
13941385
"next_poll_in", "5m")
13951386
} else {
13961387
// Save updated thread info (cache + persist)
1397-
c.saveThread(owner, repo, prNumber, channelID, ThreadInfo{
1388+
c.saveThread(owner, repo, prNumber, channelID, cache.ThreadInfo{
13981389
ThreadTS: threadTS,
13991390
ChannelID: channelID,
14001391
LastState: prState,

pkg/bot/bot_sprinkler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func (c *Coordinator) lookupPRsForCheckEvent(ctx context.Context, event client.E
162162
}
163163

164164
// Process the PR update since we have fresh data
165+
//nolint:contextcheck // Background context intentional - goroutine must outlive parent timeout
165166
go c.handlePullRequestEventWithData(context.Background(), owner, repo, struct {
166167
Action string `json:"action"`
167168
PullRequest struct {

pkg/bot/bot_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func TestSaveThread(t *testing.T) {
172172

173173
mockState := &mockStateStore{
174174
processedEvents: make(map[string]bool),
175-
threads: make(map[string]ThreadInfo),
175+
threads: make(map[string]cache.ThreadInfo),
176176
}
177177

178178
c := &Coordinator{
@@ -185,7 +185,7 @@ func TestSaveThread(t *testing.T) {
185185
eventSemaphore: make(chan struct{}, 10),
186186
}
187187

188-
threadInfo := ThreadInfo{
188+
threadInfo := cache.ThreadInfo{
189189
ChannelID: "C123456",
190190
ThreadTS: "1234567890.123456",
191191
}
@@ -225,7 +225,7 @@ func TestSaveThread_PersistenceError(t *testing.T) {
225225

226226
mockState := &mockStateStore{
227227
processedEvents: make(map[string]bool),
228-
threads: make(map[string]ThreadInfo),
228+
threads: make(map[string]cache.ThreadInfo),
229229
saveThreadErr: errors.New("database error"),
230230
}
231231

@@ -239,7 +239,7 @@ func TestSaveThread_PersistenceError(t *testing.T) {
239239
eventSemaphore: make(chan struct{}, 10),
240240
}
241241

242-
threadInfo := ThreadInfo{
242+
threadInfo := cache.ThreadInfo{
243243
ChannelID: "C123456",
244244
ThreadTS: "1234567890.123456",
245245
}
@@ -268,7 +268,7 @@ func TestSaveThread_PersistenceError(t *testing.T) {
268268
func TestThreadCache_Set(t *testing.T) {
269269
threadCache := cache.New()
270270

271-
threadInfo := ThreadInfo{
271+
threadInfo := cache.ThreadInfo{
272272
ChannelID: "C123456",
273273
ThreadTS: "1234567890.123456",
274274
MessageText: "Test message",

pkg/bot/commit_pr_cache_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestCheckEventIntegration_CacheHit(t *testing.T) {
137137

138138
// Create coordinator with real commit cache
139139
coord := &Coordinator{
140-
stateStore: mockStore,
140+
stateStore: mockStore,
141141
commitPRCache: cache.NewCommitPRCache(),
142142
github: &mockGitHubClientForCache{
143143
// Mock should NOT be called if cache works
@@ -185,7 +185,7 @@ func TestCheckEventIntegration_CacheMissFallback(t *testing.T) {
185185

186186
// Create coordinator with empty cache
187187
coord := &Coordinator{
188-
stateStore: mockStore,
188+
stateStore: mockStore,
189189
commitPRCache: cache.NewCommitPRCache(),
190190
github: &mockGitHubClientForCache{
191191
// Mock SHOULD be called on cache miss

pkg/bot/coordinator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func TestCoordinator_saveThread(t *testing.T) {
1111
// Create mock state store
1212
mockStore := &mockStateStore{
13-
threads: make(map[string]ThreadInfo),
13+
threads: make(map[string]cache.ThreadInfo),
1414
}
1515

1616
// Create coordinator with mock
@@ -24,7 +24,7 @@ func TestCoordinator_saveThread(t *testing.T) {
2424
repo := "testrepo"
2525
number := 123
2626
channelID := "C123"
27-
info := ThreadInfo{
27+
info := cache.ThreadInfo{
2828
ThreadTS: "1234567890.123456",
2929
MessageText: "Test PR message",
3030
ChannelID: channelID,

0 commit comments

Comments
 (0)