From a064ec6fc1c28c7e25cda43e5efbf2397acfa8a0 Mon Sep 17 00:00:00 2001 From: Jeanette Tan Date: Wed, 26 Apr 2023 22:22:31 +0800 Subject: [PATCH] Fix lint --- cmd/compact/main.go | 4 ++-- discovery/xds/kuma_mads.pb.go | 4 ++-- model/labels/regexp.go | 11 ++++++----- tsdb/compact.go | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/compact/main.go b/cmd/compact/main.go index 7cc4b75934..3275c18e64 100644 --- a/cmd/compact/main.go +++ b/cmd/compact/main.go @@ -73,7 +73,7 @@ func main() { c, err := tsdb.NewLeveledCompactorWithChunkSize(ctx, nil, logger, []int64{0}, nil, segmentSizeMB*1024*1024, nil, true) if err != nil { - log.Fatalln("creating compator", err) + log.Panicln("creating compactor", err) } opts := tsdb.DefaultLeveledCompactorConcurrencyOptions() @@ -84,6 +84,6 @@ func main() { _, err = c.CompactWithSplitting(outputDir, blockDirs, nil, uint64(shardCount)) if err != nil { - log.Fatalln("compacting", err) + log.Panicln("compacting", err) } } diff --git a/discovery/xds/kuma_mads.pb.go b/discovery/xds/kuma_mads.pb.go index b1079bf23f..e1160d7756 100644 --- a/discovery/xds/kuma_mads.pb.go +++ b/discovery/xds/kuma_mads.pb.go @@ -132,13 +132,13 @@ type MonitoringAssignment_Target struct { // E.g., `backend-01` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Scheme on which to scrape the target. - //E.g., `http` + // E.g., `http` Scheme string `protobuf:"bytes,2,opt,name=scheme,proto3" json:"scheme,omitempty"` // Address (preferably IP) for the service // E.g., `backend.svc` or `10.1.4.32:9090` Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` // Optional path to append to the address for scraping - //E.g., `/metrics` + // E.g., `/metrics` MetricsPath string `protobuf:"bytes,4,opt,name=metrics_path,json=metricsPath,proto3" json:"metrics_path,omitempty"` // Arbitrary labels associated with that particular target. // diff --git a/model/labels/regexp.go b/model/labels/regexp.go index 52729c26c9..df420ac846 100644 --- a/model/labels/regexp.go +++ b/model/labels/regexp.go @@ -195,7 +195,7 @@ func findSetMatchesInternal(re *syntax.Regexp, base string) (matches []string, c } var matches []string var totalSet int - for i := 0; i+1 < len(re.Rune); i = i + 2 { + for i := 0; i+1 < len(re.Rune); i += 2 { totalSet += int(re.Rune[i+1]-re.Rune[i]) + 1 } // limits the total characters that can be used to create matches. @@ -204,7 +204,7 @@ func findSetMatchesInternal(re *syntax.Regexp, base string) (matches []string, c if totalSet > maxSetMatches { return nil, false } - for i := 0; i+1 < len(re.Rune); i = i + 2 { + for i := 0; i+1 < len(re.Rune); i += 2 { lo, hi := re.Rune[i], re.Rune[i+1] for c := lo; c <= hi; c++ { matches = append(matches, base+string(c)) @@ -566,7 +566,8 @@ type containsStringMatcher struct { func (m *containsStringMatcher) Matches(s string) bool { for _, substr := range m.substrings { - if m.right != nil && m.left != nil { + switch { + case m.right != nil && m.left != nil: searchStartPos := 0 for { @@ -588,12 +589,12 @@ func (m *containsStringMatcher) Matches(s string) bool { // Continue searching for another occurrence of the substring inside the text. searchStartPos = pos + 1 } - } else if m.left != nil { + case m.left != nil: // If we have to check for characters on the left then we need to match a suffix. if strings.HasSuffix(s, substr) && m.left.Matches(s[:len(s)-len(substr)]) { return true } - } else if m.right != nil { + case m.right != nil: if strings.HasPrefix(s, substr) && m.right.Matches(s[len(substr):]) { return true } diff --git a/tsdb/compact.go b/tsdb/compact.go index ed349b6330..23c6da41f7 100644 --- a/tsdb/compact.go +++ b/tsdb/compact.go @@ -594,7 +594,7 @@ func (c *LeveledCompactor) compactOOO(dest string, oooHead *OOOCompactionHead, s blockSize := oooHead.ChunkRange() oooHeadMint, oooHeadMaxt := oooHead.MinTime(), oooHead.MaxTime() ulids := make([][]ulid.ULID, 0) - for t := blockSize * (oooHeadMint / blockSize); t <= oooHeadMaxt; t = t + blockSize { + for t := blockSize * (oooHeadMint / blockSize); t <= oooHeadMaxt; t += blockSize { mint, maxt := t, t+blockSize outBlocks = append(outBlocks, make([]shardedBlock, shardCount))