diff --git a/.golangci.yml b/.golangci.yml index f350aed6d..a85a76cdf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -27,6 +27,7 @@ linters: - unconvert - unused - usestdlibvars + - whitespace issues: max-same-issues: 0 diff --git a/cmd/promtool/rules_test.go b/cmd/promtool/rules_test.go index 75aad6786..d55fb0c89 100644 --- a/cmd/promtool/rules_test.go +++ b/cmd/promtool/rules_test.go @@ -78,7 +78,6 @@ func TestBackfillRuleIntegration(t *testing.T) { // Execute the test more than once to simulate running the rule importer twice with the same data. // We expect duplicate blocks with the same series are created when run more than once. for i := 0; i < tt.runcount; i++ { - ruleImporter, err := newTestRuleImporter(ctx, start, tmpDir, tt.samples, tt.maxBlockDuration) require.NoError(t, err) path1 := filepath.Join(tmpDir, "test.file") diff --git a/discovery/eureka/eureka.go b/discovery/eureka/eureka.go index deed89f6f..779c081ae 100644 --- a/discovery/eureka/eureka.go +++ b/discovery/eureka/eureka.go @@ -228,7 +228,6 @@ func targetsForApp(app *Application) []model.LabelSet { } targets = append(targets, target) - } return targets } diff --git a/discovery/hetzner/robot.go b/discovery/hetzner/robot.go index 2cf6006f8..b862c33f5 100644 --- a/discovery/hetzner/robot.go +++ b/discovery/hetzner/robot.go @@ -122,7 +122,6 @@ func (d *robotDiscovery) refresh(context.Context) ([]*targetgroup.Group, error) labels[hetznerLabelPublicIPv6Network] = model.LabelValue(fmt.Sprintf("%s/%s", subnet.IP, subnet.Mask)) break } - } targets[i] = labels } diff --git a/discovery/marathon/marathon.go b/discovery/marathon/marathon.go index f833af47e..3e9e15967 100644 --- a/discovery/marathon/marathon.go +++ b/discovery/marathon/marathon.go @@ -453,7 +453,6 @@ func targetsForApp(app *app) []model.LabelSet { // Gather info about the app's 'tasks'. Each instance (container) is considered a task // and can be reachable at one or more host:port endpoints. for _, t := range app.Tasks { - // There are no labels to gather if only Ports is defined. (eg. with host networking) // Ports can only be gathered from the Task (not from the app) and are guaranteed // to be the same across all tasks. If we haven't gathered any ports by now, @@ -464,7 +463,6 @@ func targetsForApp(app *app) []model.LabelSet { // Iterate over the ports we gathered using one of the methods above. for i, port := range ports { - // A zero port here means that either the portMapping has a zero port defined, // or there is a portDefinition with requirePorts set to false. This means the port // is auto-generated by Mesos and needs to be looked up in the task. @@ -516,7 +514,6 @@ func extractPortMapping(portMappings []portMapping, containerNet bool) ([]uint32 labels := make([]map[string]string, len(portMappings)) for i := 0; i < len(portMappings); i++ { - labels[i] = portMappings[i].Labels if containerNet { diff --git a/discovery/moby/nodes.go b/discovery/moby/nodes.go index 85092f907..a7c5551c0 100644 --- a/discovery/moby/nodes.go +++ b/discovery/moby/nodes.go @@ -80,7 +80,6 @@ func (d *Discovery) refreshNodes(ctx context.Context) ([]*targetgroup.Group, err labels[model.AddressLabel] = model.LabelValue(addr) tg.Targets = append(tg.Targets, labels) - } return []*targetgroup.Group{tg}, nil } diff --git a/discovery/scaleway/instance.go b/discovery/scaleway/instance.go index 67311216d..9dd786c80 100644 --- a/discovery/scaleway/instance.go +++ b/discovery/scaleway/instance.go @@ -190,7 +190,6 @@ func (d *instanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group, targets = append(targets, labels) } - } return []*targetgroup.Group{{Source: "scaleway", Targets: targets}}, nil diff --git a/discovery/zookeeper/zookeeper.go b/discovery/zookeeper/zookeeper.go index 7d8761527..303c7ca6d 100644 --- a/discovery/zookeeper/zookeeper.go +++ b/discovery/zookeeper/zookeeper.go @@ -291,7 +291,6 @@ func parseServersetMember(data []byte, path string) (model.LabelSet, error) { endpoint.Host) labels[serversetEndpointLabelPrefix+"_port_"+cleanName] = model.LabelValue( fmt.Sprintf("%d", endpoint.Port)) - } labels[serversetStatusLabel] = model.LabelValue(member.Status) diff --git a/promql/functions.go b/promql/functions.go index 0cfbcc345..2e15a1467 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -342,7 +342,6 @@ func funcHoltWinters(vals []parser.Value, args parser.Expressions, enh *EvalNode // Run the smoothing operation. var x, y float64 for i := 1; i < l; i++ { - // Scale the raw value against the smoothing factor. x = sf * samples.Floats[i].F @@ -1240,7 +1239,6 @@ func funcHistogramQuantile(vals []parser.Value, args parser.Expressions, enh *Ev enh.signatureToMetricWithBuckets[string(enh.lblBuf)] = mb } mb.buckets = append(mb.buckets, bucket{upperBound, sample.F}) - } // Now deal with the histograms. diff --git a/promql/parser/parse.go b/promql/parser/parse.go index eca439652..2679336d6 100644 --- a/promql/parser/parse.go +++ b/promql/parser/parse.go @@ -258,7 +258,6 @@ func ParseSeriesDesc(input string) (labels labels.Labels, values []SequenceValue labels = result.labels values = result.values - } if len(p.parseErrors) != 0 { diff --git a/promql/test.go b/promql/test.go index 2a9a4a2b8..1cdfe8d31 100644 --- a/promql/test.go +++ b/promql/test.go @@ -567,7 +567,6 @@ func (ev *evalCmd) compareResult(result parser.Value) error { return fmt.Errorf("expected histogram value at index %v (t=%v) for %s to be %v, but got %v (result has %s)", i, actual.T, ev.metrics[hash], expected.H, actual.H, formatSeriesResult(s)) } } - } for hash := range ev.expected { diff --git a/rules/manager_test.go b/rules/manager_test.go index 4215ca4e4..50ab6b861 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -336,7 +336,6 @@ func TestForStateAddSamples(t *testing.T) { for _, aa := range rule.ActiveAlerts() { require.Zero(t, aa.Labels.Get(model.MetricNameLabel), "%s label set on active alert: %s", model.MetricNameLabel, aa.Labels) } - } } @@ -1824,7 +1823,6 @@ func TestDependencyMapUpdatesOnGroupUpdate(t *testing.T) { } else { require.Equal(t, orig[h], depMap) } - } // Groups will be recreated when updated. @@ -1962,7 +1960,6 @@ func TestAsyncRuleEvaluation(t *testing.T) { require.Less(t, time.Since(start).Seconds(), (time.Duration(ruleCount) * artificialDelay).Seconds()) // Each rule produces one vector. require.EqualValues(t, ruleCount, testutil.ToFloat64(group.metrics.GroupSamples)) - } }) diff --git a/scrape/manager.go b/scrape/manager.go index e805fd43a..a7a8b828e 100644 --- a/scrape/manager.go +++ b/scrape/manager.go @@ -185,7 +185,6 @@ func (m *Manager) reload() { sp.Sync(groups) wg.Done() }(m.scrapePools[setName], groups) - } m.mtxScrape.Unlock() wg.Wait() diff --git a/scrape/manager_test.go b/scrape/manager_test.go index 51af45f8c..c8d9bd698 100644 --- a/scrape/manager_test.go +++ b/scrape/manager_test.go @@ -583,7 +583,6 @@ func TestManagerTargetsUpdates(t *testing.T) { tgSent := make(map[string][]*targetgroup.Group) for x := 0; x < 10; x++ { - tgSent[strconv.Itoa(x)] = []*targetgroup.Group{ { Source: strconv.Itoa(x), diff --git a/scrape/target_test.go b/scrape/target_test.go index 413fbc1b8..f91e31050 100644 --- a/scrape/target_test.go +++ b/scrape/target_test.go @@ -592,7 +592,6 @@ func TestMaxSchemaAppender(t *testing.T) { _, err = app.AppendHistogram(0, lbls, ts, nil, fh) require.Equal(t, c.expectSchema, fh.Schema) require.NoError(t, err) - } else { h := c.h.Copy() _, err = app.AppendHistogram(0, lbls, ts, h, nil) diff --git a/storage/merge_test.go b/storage/merge_test.go index c3a4725aa..0e63affbb 100644 --- a/storage/merge_test.go +++ b/storage/merge_test.go @@ -377,7 +377,6 @@ func TestMergeChunkQuerierWithNoVerticalChunkSeriesMerger(t *testing.T) { actChks, actErr := ExpandChunks(actualSeries.Iterator(nil)) require.Equal(t, expErr, actErr) require.Equal(t, expChks, actChks) - } require.NoError(t, merged.Err()) require.False(t, tc.expected.Next(), "Expected Next() to be false") diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go index 028120c05..e32a3ace0 100644 --- a/storage/remote/queue_manager_test.go +++ b/storage/remote/queue_manager_test.go @@ -845,7 +845,6 @@ func (c *TestWriteClient) Store(_ context.Context, req []byte, _ int) error { } else { c.receivedHistograms[seriesName] = append(c.receivedHistograms[seriesName], histogram) } - } } if c.withWaitGroup { diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index d0d96b09d..bb6b8423a 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -135,7 +135,6 @@ func (h *writeHandler) write(ctx context.Context, req *prompb.WriteRequest) (err } return err } - } for _, ep := range ts.Exemplars { diff --git a/tsdb/block_test.go b/tsdb/block_test.go index 21e20a61c..6d15d1838 100644 --- a/tsdb/block_test.go +++ b/tsdb/block_test.go @@ -459,7 +459,6 @@ func TestLabelNamesWithMatchers(t *testing.T) { "unique", fmt.Sprintf("value%d", i), ), []chunks.Sample{sample{100, 0, nil, nil}})) } - } blockDir := createBlock(t, tmpdir, seriesEntries) diff --git a/tsdb/chunkenc/histogram_meta.go b/tsdb/chunkenc/histogram_meta.go index 70f129b95..9aae485a8 100644 --- a/tsdb/chunkenc/histogram_meta.go +++ b/tsdb/chunkenc/histogram_meta.go @@ -73,7 +73,6 @@ func readHistogramChunkLayoutSpans(b *bstreamReader) ([]histogram.Span, error) { return nil, err } for i := 0; i < int(num); i++ { - length, err := readVarbitUint(b) if err != nil { return nil, err diff --git a/tsdb/db.go b/tsdb/db.go index d675635d7..22292ab16 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -1766,7 +1766,6 @@ func OverlappingBlocks(bm []BlockMeta) Overlaps { // Fetch the critical overlapped time range foreach overlap groups. overlapGroups := Overlaps{} for _, overlap := range overlaps { - minRange := TimeRange{Min: 0, Max: math.MaxInt64} for _, b := range overlap { if minRange.Max > b.MaxTime { diff --git a/tsdb/head_append.go b/tsdb/head_append.go index 23c2c0fbd..efd573b41 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -1275,7 +1275,6 @@ func (s *memSeries) appendPreprocessor(t int64, e chunkenc.Encoding, o chunkOpts // encoding. So we cut a new chunk with the expected encoding. c = s.cutNewHeadChunk(t, e, o.chunkRange) chunkCreated = true - } numSamples := c.chunk.NumSamples() diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 750c8a11e..d9631b3b9 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -1215,7 +1215,6 @@ func TestHeadDeleteSimple(t *testing.T) { for _, smpl := range smplsAll { _, err := app.Append(0, lblsDefault, smpl.t, smpl.f) require.NoError(t, err) - } require.NoError(t, app.Commit()) @@ -1229,7 +1228,6 @@ func TestHeadDeleteSimple(t *testing.T) { for _, smpl := range c.addSamples { _, err := app.Append(0, lblsDefault, smpl.t, smpl.f) require.NoError(t, err) - } require.NoError(t, app.Commit()) @@ -3851,7 +3849,6 @@ func TestChunkSnapshot(t *testing.T) { } { // Additional data to only include in WAL and m-mapped chunks and not snapshot. This mimics having an old snapshot on disk. - // Add more samples. app := head.Appender(context.Background()) for i := 1; i <= numSeries; i++ { diff --git a/tsdb/head_wal.go b/tsdb/head_wal.go index dd836a537..076768f4e 100644 --- a/tsdb/head_wal.go +++ b/tsdb/head_wal.go @@ -1323,7 +1323,6 @@ func DeleteChunkSnapshots(dir string, maxIndex, maxOffset int) error { errs.Add(err) } } - } return errs.Err() } diff --git a/tsdb/index/index.go b/tsdb/index/index.go index 7ab890b99..89c2041a7 100644 --- a/tsdb/index/index.go +++ b/tsdb/index/index.go @@ -1528,7 +1528,6 @@ func (r *Reader) LabelValues(ctx context.Context, name string, matchers ...*labe values = append(values, k) } return values, nil - } e, ok := r.postings[name] if !ok { diff --git a/tsdb/querier.go b/tsdb/querier.go index 2ee7f5153..8ebedfe52 100644 --- a/tsdb/querier.go +++ b/tsdb/querier.go @@ -844,7 +844,6 @@ func (p *populateWithDelChunkSeriesIterator) Next() bool { return true } } - } return false } diff --git a/tsdb/wlog/watcher.go b/tsdb/wlog/watcher.go index b92494468..8ebd9249a 100644 --- a/tsdb/wlog/watcher.go +++ b/tsdb/wlog/watcher.go @@ -213,7 +213,6 @@ func (w *Watcher) setMetrics() { w.samplesSentPreTailing = w.metrics.samplesSentPreTailing.WithLabelValues(w.name) w.currentSegmentMetric = w.metrics.currentSegment.WithLabelValues(w.name) w.notificationsSkipped = w.metrics.notificationsSkipped.WithLabelValues(w.name) - } }