Skip to content

Commit

Permalink
fix linter (forgot to include in commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed May 10, 2022
1 parent 5fa538a commit e2ece4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/job/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ func (r *Runner) Run(ctx context.Context, logger *zap.Logger) {
return
}

if r.reporter != nil && metric != nil {
reportMetrics(r.reporter, metric, r.globalJobsCfg.ClientID, logger)
}
reportMetrics(r.reporter, metric, r.globalJobsCfg.ClientID, logger)
}
}

Expand All @@ -160,7 +158,7 @@ func computeCount(count int, scaleFactor float64) int {
}

// if we have less than 1 goroutine per job we just filter them randomly so that only jobs*scaledCount pass
if rand.Float64() < scaledCount {
if rand.Float64() < scaledCount { //nolint:gosec // Cryptographically secure random not required
return 1
}

Expand Down Expand Up @@ -219,9 +217,11 @@ func (r *Runner) runJobs(ctx context.Context, cfg *config.MultiConfig, metric *m
}

func reportMetrics(reporter metrics.Reporter, metric *metrics.Metrics, clientID string, logger *zap.Logger) {
reporter.WriteSummary(metric)
if reporter != nil && metric != nil {
reporter.WriteSummary(metric)

if err := metrics.ReportStatistics(int64(metric.Sum(metrics.BytesSentStat)), clientID); err != nil {
logger.Debug("error reporting statistics", zap.Error(err))
if err := metrics.ReportStatistics(int64(metric.Sum(metrics.BytesSentStat)), clientID); err != nil {
logger.Debug("error reporting statistics", zap.Error(err))
}
}
}
6 changes: 4 additions & 2 deletions src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ func GetEnvFloatDefault(key string, defaultValue float64) float64 {
return defaultValue
}

v, err := strconv.ParseFloat(value, 64)
const floatBits = 64

v, err := strconv.ParseFloat(value, floatBits)
if err != nil {
return defaultValue
}

return v
}

func Max[T int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float32|float64](a, b T) T {
func Max[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64](a, b T) T {
if a > b {
return a
}
Expand Down

0 comments on commit e2ece4c

Please sign in to comment.