Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: Fix new detected lint complaints #5080

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions cmd/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions cmd/speedtest-spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading