Skip to content

Commit 4801a85

Browse files
authored
feat: enable predeclared and nlreturn (#241)
1 parent cb8bbc5 commit 4801a85

12 files changed

Lines changed: 18 additions & 3 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ linters:
77
- cyclop # some functions need refactoring, I'll deal with that later
88
- exhaustruct # it's ok not to specify all the fields in a struct definition
99
- godox # I like leaving TODOs in the code
10-
- nlreturn # keeps the code concise
11-
- predeclared # need to rename the print action
1210
- testpackage # keep the tests close to the code
1311
- varnamelen # short variable names are okay
1412

internal/actions/assign/assign.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (a *Runner) Run(n *notifications.Notification, assignees []string, w io.Wri
5656
url, ok := issueURL(n.Subject.URL)
5757
if !ok {
5858
slog.Warn("not an issue or pull", "notification", n)
59+
5960
return nil
6061
}
6162

internal/actions/print/print.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Package print implements an [actions.Runner] that prints a notification.
33
*/
4-
//nolint:forbidigo // This action is correctly named.
4+
//nolint:forbidigo,predeclared // This action is correctly named.
55
package print
66

77
import (

internal/cache/cache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (c *File) Read(out any) error {
4848
if err != nil {
4949
if errors.Is(err, os.ErrNotExist) {
5050
slog.Debug("cache doesn't exist", "path", c.path)
51+
5152
return nil
5253
}
5354

internal/cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,13 @@ func runRoot(_ *cobra.Command, _ []string) error {
107107
n, err := filter(n)
108108
if err != nil {
109109
slog.Error("Failed to filter the notifications", "err", err)
110+
110111
return err
111112
}
112113

113114
if err := display(n); err != nil {
114115
slog.Error("Failed to display the notifications", "err", err)
116+
115117
return err
116118
}
117119

@@ -156,6 +158,7 @@ func filter(n notifications.Notifications) (notifications.Notifications, error)
156158

157159
if !found {
158160
slog.Error("Rule not found", "rule", ruleFlag)
161+
159162
return nil, fmt.Errorf("invalid rule '%s': %w", ruleFlag, errRuleNotFound)
160163
}
161164
}

internal/gh/gh.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func (c *Client) retry(verb, endpoint string, body io.Reader) ([]*notifications.
128128

129129
if isRetryable(err) {
130130
slog.Warn("endpoint failed with retryable error", "error", err, "endpoint", endpoint, "retry left", i)
131+
131132
continue
132133
}
133134

internal/manager/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func (m *Manager) Apply() error {
118118
runner, ok := m.Actions[rule.Action]
119119
if !ok {
120120
slog.Error("unknown action", "action", rule.Action)
121+
121122
continue
122123
}
123124

@@ -131,12 +132,14 @@ func (m *Manager) Apply() error {
131132
for _, notification := range selectedNotifications {
132133
if notification.Meta.Done && !m.ForceStrategy.Has(ForceApply) {
133134
slog.Debug("skipping done notification", "id", notification.ID)
135+
134136
continue
135137
}
136138

137139
if m.ForceStrategy.Has(ForceNoop) {
138140
//nolint:forbidigo // This is an expected print statement.
139141
fmt.Printf("NOOP'ing action %s on notification %s\n", rule.Action, notification.String())
142+
140143
continue
141144
}
142145

internal/manager/strategies.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ func (r *RefreshStrategy) ShouldRefresh(expired bool) bool {
4545
switch *r {
4646
case ForceRefresh:
4747
slog.Info("forcing a refresh")
48+
4849
return true
4950

5051
case PreventRefresh:
5152
slog.Info("preventing a refresh")
53+
5254
return false
5355

5456
case AutoRefresh:
5557
fallthrough
5658
default:
5759
slog.Debug("refresh based on cache expiration", "expired", expired)
60+
5861
return expired
5962
}
6063
}

internal/notifications/notifications.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func (n Notifications) Equal(others Notifications) bool {
100100
for i, n := range n {
101101
if !n.Equal(others[i]) {
102102
slog.Info("notification not equal", "n", n.Debug(), "other", others[i].Debug())
103+
103104
return false
104105
}
105106
}

internal/notifications/sync.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func Sync(local, remote Notifications) Notifications {
6969
if local[i].Meta.Done || local[i].Meta.Hidden {
7070
// (4) Drop
7171
slog.Debug("sync", "action", "drop", "id", local[i].ID)
72+
7273
continue
7374
}
7475

0 commit comments

Comments
 (0)