From 85ebca52fd8d711dc0303e6872392bb2b03e0bea Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 11 Feb 2026 13:08:46 +0100 Subject: [PATCH] modernize: minmax go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest modernize -minmax -fix ./... Signed-off-by: Sebastiaan van Stijn --- cli/command/image/tree.go | 5 +---- cli/command/service/list_test.go | 5 +---- cli/command/service/progress/progress.go | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cli/command/image/tree.go b/cli/command/image/tree.go index 70b7482867..6616e9e207 100644 --- a/cli/command/image/tree.go +++ b/cli/command/image/tree.go @@ -389,10 +389,7 @@ func generateLegend(out tui.Output, width uint) string { } legend += legendSb371.String() - r := int(width) - tui.Width(legend) - if r < 0 { - r = 0 - } + r := max(int(width)-tui.Width(legend), 0) legend = strings.Repeat(" ", r) + legend return legend } diff --git a/cli/command/service/list_test.go b/cli/command/service/list_test.go index 8d6462e0bd..78bedbac51 100644 --- a/cli/command/service/list_test.go +++ b/cli/command/service/list_test.go @@ -191,10 +191,7 @@ func generateServices(t *testing.T, opts clusterOpts) client.ServiceListResult { t.Helper() // Can't have more global tasks than nodes - globalTasks := opts.runningTasks - if globalTasks > opts.activeNodes { - globalTasks = opts.activeNodes - } + globalTasks := min(opts.runningTasks, opts.activeNodes) return client.ServiceListResult{ Items: []swarm.Service{ *builders.Service( diff --git a/cli/command/service/progress/progress.go b/cli/command/service/progress/progress.go index a4de39b8fb..94b59d950e 100644 --- a/cli/command/service/progress/progress.go +++ b/cli/command/service/progress/progress.go @@ -662,10 +662,7 @@ func (u *replicatedJobProgressUpdater) writeOverallProgress(active, completed in }) // actualDesired is the lesser of MaxConcurrent, or the remaining tasks - actualDesired := u.total - completed - if actualDesired > u.concurrent { - actualDesired = u.concurrent - } + actualDesired := min(u.total-completed, u.concurrent) _ = u.progressOut.WriteProgress(progress.Progress{ ID: "active tasks",