Skip to content

Commit 85ebca5

Browse files
committed
modernize: minmax
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest modernize -minmax -fix ./... Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent e8dc2fc commit 85ebca5

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

‎cli/command/image/tree.go‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,7 @@ func generateLegend(out tui.Output, width uint) string {
389389
}
390390
legend += legendSb371.String()
391391

392-
r := int(width) - tui.Width(legend)
393-
if r < 0 {
394-
r = 0
395-
}
392+
r := max(int(width)-tui.Width(legend), 0)
396393
legend = strings.Repeat(" ", r) + legend
397394
return legend
398395
}

‎cli/command/service/list_test.go‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ func generateServices(t *testing.T, opts clusterOpts) client.ServiceListResult {
191191
t.Helper()
192192

193193
// Can't have more global tasks than nodes
194-
globalTasks := opts.runningTasks
195-
if globalTasks > opts.activeNodes {
196-
globalTasks = opts.activeNodes
197-
}
194+
globalTasks := min(opts.runningTasks, opts.activeNodes)
198195
return client.ServiceListResult{
199196
Items: []swarm.Service{
200197
*builders.Service(

‎cli/command/service/progress/progress.go‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,7 @@ func (u *replicatedJobProgressUpdater) writeOverallProgress(active, completed in
662662
})
663663

664664
// actualDesired is the lesser of MaxConcurrent, or the remaining tasks
665-
actualDesired := u.total - completed
666-
if actualDesired > u.concurrent {
667-
actualDesired = u.concurrent
668-
}
665+
actualDesired := min(u.total-completed, u.concurrent)
669666

670667
_ = u.progressOut.WriteProgress(progress.Progress{
671668
ID: "active tasks",

0 commit comments

Comments
 (0)