Skip to content

Commit d4401ed

Browse files
committedNov 18, 2024··
fix or ignore issues found by golangci-lint
1 parent 2eef600 commit d4401ed

File tree

13 files changed

+24
-24
lines changed

13 files changed

+24
-24
lines changed
 

‎cmd/goordinator/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ func mustParseCommandlineParams() {
203203
}
204204

205205
pflag.Parse()
206-
207206
}
208207

209208
func mustParseCfg() *cfg.Config {
@@ -382,7 +381,7 @@ func main() {
382381

383382
if *args.ShowVersion {
384383
fmt.Printf("%s %s\n", appName, Version)
385-
os.Exit(0)
384+
os.Exit(0) // nolint:gocritic // defer functions won't run
386385
}
387386

388387
config := mustParseCfg()

‎internal/autoupdate/autoupdate.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ func NewAutoupdater(
146146
}
147147

148148
return &a
149-
150149
}
151150

152151
// branchRefToRef returns ref without a leading refs/heads/ prefix.
@@ -731,6 +730,7 @@ func (a *Autoupdater) processPushEvent(ctx context.Context, logger *zap.Logger,
731730

732731
a.ResumeAllForBaseBranch(ctx, bb)
733732
}
733+
734734
func (a *Autoupdater) processPullRequestReviewEvent(ctx context.Context, logger *zap.Logger, ev *github.PullRequestReviewEvent) {
735735
owner := ev.GetRepo().GetOwner().GetLogin()
736736
repo := ev.GetRepo().GetName()
@@ -1201,7 +1201,6 @@ func (a *Autoupdater) ChangeBaseBranch(
12011201

12021202
if err := a.Enqueue(ctx, newBaseBranch, pr); err != nil {
12031203
return fmt.Errorf("could not enqueue in queue for new base branch: %w", err)
1204-
12051204
}
12061205

12071206
return nil

‎internal/autoupdate/autoupdate_test.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ import (
2323
github_prov "github.com/simplesurance/goordinator/internal/provider/github"
2424
)
2525

26-
const repo = "repo"
27-
const repoOwner = "testman"
28-
const queueHeadLabel = "first"
26+
const (
27+
repo = "repo"
28+
repoOwner = "testman"
29+
queueHeadLabel = "first"
30+
)
2931

30-
const condCheckInterval = 20 * time.Millisecond
31-
const condWaitTimeout = 5 * time.Second
32+
const (
33+
condCheckInterval = 20 * time.Millisecond
34+
condWaitTimeout = 5 * time.Second
35+
)
3236

3337
// mustGetActivePR fetches from the base-branch queue of the autoupdater the
3438
// pull request with the given pull request number.
@@ -1571,7 +1575,6 @@ func TestBaseBranchUpdatesBlockUntilFinished(t *testing.T) {
15711575
require.Eventually(t, func() bool {
15721576
return queue.getExecuting() == nil
15731577
}, queue.updateBranchPollInterval+2*time.Second, queue.updateBranchPollInterval/2)
1574-
15751578
}
15761579

15771580
func TestPRHeadLabelIsAppliedToNextAfterMerge(t *testing.T) {

‎internal/autoupdate/events_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func newBasicPullRequestEvent(prNumber int, branchName, baseBranchName string) *
2222
},
2323
}
2424
}
25+
2526
func newBasicPullRequest(prNumber int, baseBranchName, branchName string) *github.PullRequest {
2627
return &github.PullRequest{
2728
Number: &prNumber,
@@ -71,6 +72,7 @@ func newPullRequestAutomergeEnabledEvent(prNumber int, branchName, baseBranchNam
7172

7273
return pr
7374
}
75+
7476
func newPullRequestAutomergeDisabledEvent(prNumber int, branchName, baseBranchName string) *github.PullRequestEvent {
7577
pr := newBasicPullRequestEvent(prNumber, branchName, baseBranchName)
7678
pr.Action = strPtr("auto_merge_disabled")

‎internal/autoupdate/httpservice.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package autoupdate
22

33
import (
44
"embed"
5+
"html/template"
56
"io/fs"
67
"net/http"
78

89
_ "embed" // used to embed html templates and static docs
910

10-
"html/template"
11-
1211
"go.uber.org/zap"
1312
)
1413

‎internal/autoupdate/queue.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ func (q *queue) prReadyForMergeStatus(ctx context.Context, pr *PullRequest) (*gi
835835
logfields.Commit(status.Commit),
836836
logfields.ReviewDecision(string(status.ReviewDecision)),
837837
logfields.CIStatusSummary(string(status.CIStatus)),
838-
zap.Any("github.ci_statuses", status.Statuses)}, loggingFields...)...,
838+
zap.Any("github.ci_statuses", status.Statuses),
839+
}, loggingFields...)...,
839840
)
840841

841842
return nil
@@ -1065,8 +1066,8 @@ func (q *queue) Stop() {
10651066
// The function returns a Set of branch names for that no PR in the queue could
10661067
// be found.
10671068
func (q *queue) SetPRStaleSinceIfNewerByBranch(branchNames []string, t time.Time) (
1068-
notFound set.Set[string]) {
1069-
1069+
notFound set.Set[string],
1070+
) {
10701071
branchSet := set.From(branchNames)
10711072
prs, notFound := q.prsByBranch(branchSet)
10721073

‎internal/autoupdate/queue_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ func TestUpdatePRWithBaseReturnsChangedWhenScheduled(t *testing.T) {
5555
UpdateBranch(gomock.Any(), gomock.Eq(repoOwner), gomock.Eq(repo), gomock.Any()).
5656
DoAndReturn(func(context.Context, string, string, int) (*githubclt.UpdateBranchResult, error) {
5757
if updateBranchCalls == 0 {
58-
updateBranchCalls = updateBranchCalls + 1
58+
updateBranchCalls++
5959
return &githubclt.UpdateBranchResult{HeadCommitID: headCommitID, Changed: true, Scheduled: true}, nil
6060
}
61-
updateBranchCalls = updateBranchCalls + 1
61+
updateBranchCalls++
6262
return &githubclt.UpdateBranchResult{HeadCommitID: headCommitID, Changed: false, Scheduled: false}, nil
6363
}).
6464
Times(2)

‎internal/autoupdate/routines/pool_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func TestScheduleAndWait(t *testing.T) {
2525
for i := range workDone {
2626
assert.Equal(t, int32(1), atomic.LoadInt32(&workDone[i]), "work %d not done", i)
2727
}
28-
2928
}
3029

3130
func TestQueuePanicsAfterWait(t *testing.T) {

‎internal/githubclt/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (clt *Client) UpdateBranch(ctx context.Context, owner, repo string, pullReq
177177

178178
_, _, err = clt.restClt.PullRequests.UpdateBranch(ctx, owner, repo, pullRequestNumber, &github.PullRequestBranchUpdateOptions{ExpectedHeadSHA: &prHEADSHA})
179179
if err != nil {
180-
if _, ok := err.(*github.AcceptedError); ok {
180+
if _, ok := err.(*github.AcceptedError); ok { // nolint:errorlint // errors.As not needed here
181181
// It is not clear if the response ensures that the
182182
// branch will be updated or if the scheduled operation
183183
// can fail.
@@ -334,7 +334,7 @@ func (clt *Client) ListPullRequests(ctx context.Context, owner, repo, state, sor
334334
}
335335

336336
func (clt *Client) wrapRetryableErrors(err error) error {
337-
switch v := err.(type) {
337+
switch v := err.(type) { // nolint:errorlint // errors.As not needed here
338338
case *github.RateLimitError:
339339
clt.logger.Info(
340340
"rate limit exceeded",

‎internal/githubclt/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestWrapRetryableErrorsGraphql(t *testing.T) {
2121

2222
// is the same then in vendor/github.com/shurcooL/graphql/graphql.go do()
2323
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
24-
w.WriteHeader(503)
24+
w.WriteHeader(http.StatusServiceUnavailable)
2525
}))
2626

2727
t.Cleanup(srv.Close)

‎internal/goordinator/action/httprequest/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ func NewConfigFromMap(m map[string]any) (*Config, error) {
8585
data: data,
8686
logger: zap.L().Named(loggerName),
8787
}, nil
88-
8988
}
9089

9190
// Render runs renderFunc on all configuration options that can contain

‎internal/goordinator/events_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ func newPullRequestSyncHTTPReq() *http.Request {
482482
hdrs.Set("X-GitHub-Event", "pull_request")
483483

484484
return &http.Request{
485-
Method: "POST",
485+
Method: http.MethodPost,
486486
Header: hdrs,
487487
Body: io.NopCloser(strings.NewReader(pullRequestSynchronizeEventPayload)),
488488
}

‎internal/goordinator/evloop.go

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ func (e *EvLoop) scheduleAction(ctx context.Context, event *Event, action action
168168
logFieldActionResult("success"),
169169
)
170170
}()
171-
172171
}
173172

174173
// Stop stops the event loop and waits until all scheduled go-routines

0 commit comments

Comments
 (0)
Please sign in to comment.