Skip to content

Commit aea134b

Browse files
authored
Merge pull request #102 from tstromberg/main
lint upgrades & go code modernization
2 parents 458b48b + 21e99a1 commit aea134b

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ linters:
186186
arguments: [10]
187187
- name: flag-parameter # fixes are difficult
188188
disabled: true
189+
- name: bare-return
190+
disabled: true
189191

190192
rowserrcheck:
191193
# database/sql is always checked.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ LINTERS :=
251251
FIXERS :=
252252

253253
GOLANGCI_LINT_CONFIG := $(LINT_ROOT)/.golangci.yml
254-
GOLANGCI_LINT_VERSION ?= v2.5.0
254+
GOLANGCI_LINT_VERSION ?= v2.7.2
255255
GOLANGCI_LINT_BIN := $(LINT_ROOT)/out/linters/golangci-lint-$(GOLANGCI_LINT_VERSION)-$(LINT_ARCH)
256256
$(GOLANGCI_LINT_BIN):
257257
mkdir -p $(LINT_ROOT)/out/linters
@@ -298,6 +298,7 @@ fix:
298298

299299
# END: lint-install .
300300

301+
301302
# Release workflow - creates a new version tag
302303
# Usage: make release VERSION=v1.0.0
303304
release:

cmd/review-goose/notifications.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"log/slog"
7+
"maps"
78
"time"
89

910
"github.com/gen2brain/beeep"
@@ -16,9 +17,7 @@ func (app *App) processNotifications(ctx context.Context) {
1617
// Get the list of PRs that need notifications
1718
app.mu.RLock()
1819
hiddenOrgs := make(map[string]bool)
19-
for org, hidden := range app.hiddenOrgs {
20-
hiddenOrgs[org] = hidden
21-
}
20+
maps.Copy(hiddenOrgs, app.hiddenOrgs)
2221
incoming := make([]PR, len(app.incoming))
2322
copy(incoming, app.incoming)
2423
outgoing := make([]PR, len(app.outgoing))

cmd/review-goose/pr_state.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"log/slog"
5+
"maps"
56
"sync"
67
"time"
78
)
@@ -180,9 +181,7 @@ func (m *PRStateManager) BlockedPRs() map[string]*PRState {
180181
defer m.mu.RUnlock()
181182

182183
result := make(map[string]*PRState)
183-
for url, state := range m.states {
184-
result[url] = state
185-
}
184+
maps.Copy(result, m.states)
186185
return result
187186
}
188187

cmd/review-goose/sprinkler.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"log/slog"
8+
"slices"
89
"strings"
910
"sync"
1011
"time"
@@ -202,13 +203,7 @@ func (sm *sprinklerMonitor) handleEvent(event client.Event) {
202203

203204
// Check if this org is in our monitored list
204205
sm.mu.RLock()
205-
monitored := false
206-
for _, o := range sm.orgs {
207-
if o == org {
208-
monitored = true
209-
break
210-
}
211-
}
206+
monitored := slices.Contains(sm.orgs, org)
212207
orgCount := len(sm.orgs)
213208
sm.mu.RUnlock()
214209

cmd/review-goose/ui.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"log/slog"
7+
"maps"
78
"runtime"
89
"sort"
910
"strconv"
@@ -259,9 +260,7 @@ func (app *App) addPRSection(ctx context.Context, prs []PR, sectionTitle string,
259260
// Get hidden orgs with proper locking
260261
app.mu.RLock()
261262
hiddenOrgs := make(map[string]bool)
262-
for org, hidden := range app.hiddenOrgs {
263-
hiddenOrgs[org] = hidden
264-
}
263+
maps.Copy(hiddenOrgs, app.hiddenOrgs)
265264
hideStale := app.hideStaleIncoming
266265
app.mu.RUnlock()
267266

@@ -444,9 +443,7 @@ func (app *App) generateMenuTitles() []string {
444443
outgoing := make([]PR, len(app.outgoing))
445444
copy(outgoing, app.outgoing)
446445
hiddenOrgs := make(map[string]bool)
447-
for org, hidden := range app.hiddenOrgs {
448-
hiddenOrgs[org] = hidden
449-
}
446+
maps.Copy(hiddenOrgs, app.hiddenOrgs)
450447
hideStale := app.hideStaleIncoming
451448
app.mu.RUnlock()
452449

@@ -813,9 +810,7 @@ func (app *App) addStaticMenuItems(ctx context.Context) {
813810
orgs = append(orgs, org)
814811
}
815812
hiddenOrgs := make(map[string]bool)
816-
for org, hidden := range app.hiddenOrgs {
817-
hiddenOrgs[org] = hidden
818-
}
813+
maps.Copy(hiddenOrgs, app.hiddenOrgs)
819814
app.mu.RUnlock()
820815

821816
sort.Strings(orgs)

0 commit comments

Comments
 (0)