tenseleyflow/shithub / c3b4552

Browse files

actions/events: satisfy lifecycle lint (S41h)

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c3b4552d1c21a8b3cb697dc5bd6debe349440e6d
Parents
06ca804
Tree
38d6193

2 changed files

StatusFile+-
M internal/actions/lifecycle/cancel.go 2 3
M internal/web/handlers/api/runners.go 4 3
internal/actions/lifecycle/cancel.gomodified
@@ -51,8 +51,7 @@ func CancelRun(ctx context.Context, deps Deps, runID int64, reason string) (Canc
5151
 		}
5252
 	}()
5353
 
54
-	run, err := q.GetWorkflowRunByID(ctx, tx, runID)
55
-	if err != nil {
54
+	if _, err := q.GetWorkflowRunByID(ctx, tx, runID); err != nil {
5655
 		return CancelResult{}, err
5756
 	}
5857
 	changed, err := q.RequestWorkflowRunCancel(ctx, tx, runID)
@@ -75,7 +74,7 @@ func CancelRun(ctx context.Context, deps Deps, runID int64, reason string) (Canc
7574
 		if err != nil {
7675
 			return CancelResult{}, err
7776
 		}
78
-		run, err = q.GetWorkflowRunByID(ctx, tx, runID)
77
+		run, err := q.GetWorkflowRunByID(ctx, tx, runID)
7978
 		if err != nil {
8079
 			return CancelResult{}, err
8180
 		}
internal/web/handlers/api/runners.gomodified
@@ -222,16 +222,17 @@ func (h *Handlers) claimRunnerJob(
222222
 		return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, nil
223223
 	}
224224
 	run, err := q.StartWorkflowRun(ctx, tx, job.RunID)
225
-	if err == nil {
225
+	switch {
226
+	case err == nil:
226227
 		if err := actionsevents.EmitRunTx(ctx, tx, run, actionsevents.ActionRunning); err != nil {
227228
 			return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
228229
 		}
229
-	} else if errors.Is(err, pgx.ErrNoRows) {
230
+	case errors.Is(err, pgx.ErrNoRows):
230231
 		run, err = q.GetWorkflowRunByID(ctx, tx, job.RunID)
231232
 		if err != nil {
232233
 			return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
233234
 		}
234
-	} else {
235
+	default:
235236
 		return actionsdb.ClaimQueuedWorkflowJobRow{}, nil, nil, false, err
236237
 	}
237238
 	if err := actionsevents.EmitJobTx(ctx, tx, run, claimRowWorkflowJob(job), actionsevents.ActionRunning); err != nil {