From 663db1e53c4b8e9e4653421359c96a1a16ea2994 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Sun, 22 Oct 2023 18:27:23 +0300 Subject: [PATCH] Reduce cognitive complexity in Migration#Cancel Signed-off-by: Arik Hadas --- pkg/controller/plan/migration.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/controller/plan/migration.go b/pkg/controller/plan/migration.go index d449879fd..7ea5328d2 100644 --- a/pkg/controller/plan/migration.go +++ b/pkg/controller/plan/migration.go @@ -403,17 +403,21 @@ func (r *Migration) Cancel() error { } } vm.MarkCompleted() - for _, step := range vm.Pipeline { - if step.MarkedStarted() { - step.MarkCompleted() - } - } + markStartedStepsCompleted(vm.Pipeline) } } return nil } +func markStartedStepsCompleted(steps []*plan.Step) { + for _, step := range steps { + if step.MarkedStarted() { + step.MarkCompleted() + } + } +} + func (r *Migration) deletePopulatorPVCs(vm *plan.VMStatus) (err error) { if r.builder.SupportsVolumePopulators() { err = r.kubevirt.DeletePopulatedPVCs(vm)