Skip to content

Commit

Permalink
fix(ui): appease the linter gods
Browse files Browse the repository at this point in the history
These new golangci linters are a bit annoying... wsl in particular with
its "cuddling" rules--which, granted, mostly make sense--feels too
strict. Maybe gophers should be more open to different cuddling
options... ;)
  • Loading branch information
Ivan Mirić committed Oct 15, 2019
1 parent b4a776d commit 855843e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/summary.go
Expand Up @@ -96,6 +96,7 @@ func NewSummary(sts []string) *Summary {

func (s *Summary) generateCustomTrendValueResolvers(sts []string) map[string]func(s *stats.TrendSink) interface{} {
resolvers := make(map[string]func(s *stats.TrendSink) interface{})

for _, stat := range sts {
if _, exists := s.trendValueResolvers[stat]; !exists {
percentile, err := validatePercentile(stat)
Expand Down Expand Up @@ -265,6 +266,7 @@ func indentForMetric(m *stats.Metric) string {
return ""
}

// nolint:funlen
func (s *Summary) summarizeMetrics(w io.Writer, indent string, t time.Duration,
timeUnit string, metrics map[string]*stats.Metric) {
names := []string{}
Expand All @@ -290,9 +292,12 @@ func (s *Summary) summarizeMetrics(w io.Writer, indent string, t time.Duration,
m.Sink.Calc()
if sink, ok := m.Sink.(*stats.TrendSink); ok {
cols := make([]string, len(s.trendColumns))

for i, tc := range s.trendColumns {
resolver := s.trendValueResolvers[tc]
var value string

resolver := s.trendValueResolvers[tc]

switch v := resolver(sink).(type) {
case float64:
value = m.HumanizeValue(v, timeUnit)
Expand Down Expand Up @@ -324,6 +329,7 @@ func (s *Summary) summarizeMetrics(w io.Writer, indent string, t time.Duration,
}

sort.Strings(names)

tmpCols := make([]string, len(s.trendColumns))
for _, name := range names {
m := metrics[name]
Expand Down Expand Up @@ -385,5 +391,6 @@ func (s *Summary) SummarizeMetrics(w io.Writer, indent string, data SummaryData)
if data.RootGroup != nil {
summarizeGroup(w, indent+" ", data.RootGroup)
}

s.summarizeMetrics(w, indent+" ", data.Time, data.TimeUnit, data.Metrics)
}
1 change: 1 addition & 0 deletions ui/summary_test.go
Expand Up @@ -133,6 +133,7 @@ func createTestMetrics() map[string]*stats.Metric {
metrics := make(map[string]*stats.Metric)
gaugeMetric := stats.New("vus", stats.Gauge)
gaugeMetric.Sink.Add(stats.Sample{Value: 1})

countMetric := stats.New("http_reqs", stats.Counter)
countMetric.Tainted = null.BoolFrom(true)
checksMetric := stats.New("checks", stats.Rate)
Expand Down

0 comments on commit 855843e

Please sign in to comment.