From 63eb4a460953a2016f716bd105bbae9d26242d79 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Wed, 13 Nov 2024 14:46:18 +0100 Subject: [PATCH] lint: Fix new detected lint complaints (#5080) --- cmd/client.go | 4 ++-- cmd/ping.go | 20 ++++++++++---------- cmd/speedtest-spinner.go | 6 +++--- cmd/utils.go | 7 ------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/cmd/client.go b/cmd/client.go index 2a5f726ced..f842deca80 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -136,8 +136,8 @@ type Client interface { GetObjectLockConfig(ctx context.Context) (status string, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit, perr *probe.Error) // Access policy operations. - GetAccess(ctx context.Context) (access, policyJSON string, error *probe.Error) - GetAccessRules(ctx context.Context) (policyRules map[string]string, error *probe.Error) + GetAccess(ctx context.Context) (access, policyJSON string, err *probe.Error) + GetAccessRules(ctx context.Context) (policyRules map[string]string, err *probe.Error) SetAccess(ctx context.Context, access string, isJSON bool) *probe.Error // I/O operations diff --git a/cmd/ping.go b/cmd/ping.go index 6d75baab6c..8dce42262d 100644 --- a/cmd/ping.go +++ b/cmd/ping.go @@ -283,22 +283,22 @@ func pad(s, p string, count int, left bool) string { func pingStats(cliCtx *cli.Context, result madmin.AliveResult, serverMap map[string]serverStats) serverStats { var errorString string var sum, avg, dns uint64 - min := uint64(math.MaxUint64) - var max uint64 + minPing := uint64(math.MaxUint64) + var maxPing uint64 var counter, errorCount int if result.Error != nil { errorString = result.Error.Error() if stat, ok := serverMap[result.Endpoint.Host]; ok { - min = stat.min - max = stat.max + minPing = stat.min + maxPing = stat.max sum = stat.sum counter = stat.counter avg = stat.avg errorCount = stat.errorCount + 1 } else { - min = 0 + minPing = 0 errorCount = 1 } if cliCtx.IsSet("error-count") && errorCount >= cliCtx.Int("error-count") { @@ -315,21 +315,21 @@ func pingStats(cliCtx *cli.Context, result madmin.AliveResult, serverMap map[str } else { minVal = stat.min } - min = uint64(math.Min(float64(minVal), float64(uint64(result.ResponseTime)))) - max = uint64(math.Max(float64(stat.max), float64(uint64(result.ResponseTime)))) + minPing = uint64(math.Min(float64(minVal), float64(uint64(result.ResponseTime)))) + maxPing = uint64(math.Max(float64(stat.max), float64(uint64(result.ResponseTime)))) sum = stat.sum + uint64(result.ResponseTime.Nanoseconds()) counter = stat.counter + 1 } else { - min = uint64(math.Min(float64(min), float64(uint64(result.ResponseTime)))) - max = uint64(math.Max(float64(max), float64(uint64(result.ResponseTime)))) + minPing = uint64(math.Min(float64(minPing), float64(uint64(result.ResponseTime)))) + maxPing = uint64(math.Max(float64(maxPing), float64(uint64(result.ResponseTime)))) sum = uint64(result.ResponseTime) counter = 1 } avg = sum / uint64(counter) dns = uint64(result.DNSResolveTime.Nanoseconds()) } - return serverStats{min, max, sum, avg, dns, errorCount, errorString, counter} + return serverStats{minPing, maxPing, sum, avg, dns, errorCount, errorString, counter} } // mainPing is entry point for ping command. diff --git a/cmd/speedtest-spinner.go b/cmd/speedtest-spinner.go index 79c66ea1e7..35c553c417 100644 --- a/cmd/speedtest-spinner.go +++ b/cmd/speedtest-spinner.go @@ -147,11 +147,11 @@ func (m *speedTestUI) View() string { dres := m.result.DriveResult cres := m.result.ClientResult - trailerIfGreaterThan := func(in string, max int) string { - if len(in) < max { + trailerIfGreaterThan := func(in string, maxIdx int) string { + if len(in) < maxIdx { return in } - return in[:max] + "..." + return in[:maxIdx] + "..." } // Print the spinner diff --git a/cmd/utils.go b/cmd/utils.go index 6d14ab6768..6a41e402fb 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -73,13 +73,6 @@ func UTCNow() time.Time { return time.Now().UTC() } -func max(a, b int) int { - if a > b { - return a - } - return b -} - // randString generates random names and prepends them with a known prefix. func randString(n int, src rand.Source, prefix string) string { if n == 0 {