Skip to content

Commit

Permalink
fix golint issue
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Jan 14, 2024
1 parent 04610fb commit b5f3690
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
15 changes: 11 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ output:
linters:
enable:
- goimports
- revive
- gofmt
- misspell
- depguard
Expand All @@ -18,12 +19,18 @@ linters-settings:
exclude: ./.errcheck-exclude
goimports:
local-prefixes: "github.com/cortexproject/cortex"
revive:
severity: error # We only want critical issues.

depguard:
list-type: blacklist
include-go-root: true
packages-with-error-message:
- github.com/go-kit/kit/log: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
rules:
main:
list-mode: lax
files:
- $all
deny:
- pkg: "github.com/go-kit/kit/log"
desc: Use github.com/go-kit/log instead of github.com/go-kit/kit/log"

run:
timeout: 5m
Expand Down
8 changes: 0 additions & 8 deletions integration/backward_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ var (
}
)

func preCortex110Flags(flags map[string]string) map[string]string {
return e2e.MergeFlagsWithoutRemovingEmpty(flags, map[string]string{
// Store-gateway "wait ring stability" has been introduced in 1.10.0
"-store-gateway.sharding-ring.wait-stability-min-duration": "",
"-store-gateway.sharding-ring.wait-stability-max-duration": "",
})
}

func TestBackwardCompatibilityWithBlocksStorage(t *testing.T) {
for previousImage, flagsFn := range previousVersionImages {
t.Run(fmt.Sprintf("Backward compatibility upgrading from %s", previousImage), func(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,7 @@ func (d *Distributor) validateSeries(ts cortexpb.PreallocTimeseries, userID stri
histograms = make([]cortexpb.Histogram, 0, len(ts.Histograms))
// TODO(yeya24): we need to have validations for native histograms
// at some point. Skip validations for now.
for _, h := range ts.Histograms {
histograms = append(histograms, h)
}
histograms = append(histograms, ts.Histograms...)
}

return cortexpb.PreallocTimeseries{
Expand Down
5 changes: 3 additions & 2 deletions pkg/querier/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package querier

import (
"context"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/util/limiter"

"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/scrape"
"github.com/stretchr/testify/mock"

"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/prom1/storage/metric"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/cortexproject/cortex/pkg/util/limiter"
"github.com/cortexproject/cortex/pkg/util/validation"
)

Expand Down
6 changes: 4 additions & 2 deletions pkg/storage/tsdb/bucketindex/block_ids_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func TestBlockIDsFetcher_Fetch(t *testing.T) {
blockIds = append(blockIds, id)
}
}()
blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch)
_, err := blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch)
require.NoError(t, err)
close(ch)
wg.Wait()
require.Equal(t, []ulid.ULID{block3.ID}, blockIds)
Expand Down Expand Up @@ -104,7 +105,8 @@ func TestBlockIDsFetcherFetcher_Fetch_NoBucketIndex(t *testing.T) {
blockIds = append(blockIds, id)
}
}()
blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch)
_, err := blockIdsFetcher.GetActiveAndPartialBlockIDs(ctx, ch)
require.NoError(t, err)
close(ch)
wg.Wait()
require.Equal(t, []ulid.ULID{block1.ID, block2.ID, block3.ID}, blockIds)
Expand Down
11 changes: 6 additions & 5 deletions pkg/storage/tsdb/inmemory_index_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
"bytes"
"context"
"fmt"
"math/rand"
"strconv"
"strings"
"testing"
"time"

"github.com/efficientgo/core/testutil"
"github.com/go-kit/log"
"github.com/oklog/ulid"
Expand All @@ -14,11 +20,6 @@ import (
"github.com/stretchr/testify/require"
storecache "github.com/thanos-io/thanos/pkg/store/cache"
"github.com/thanos-io/thanos/pkg/tenancy"
"math/rand"
"strconv"
"strings"
"testing"
"time"
)

func TestInMemoryIndexCache_UpdateItem(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/tsdb/users_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"strings"

"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/thanos-io/objstore"

"github.com/cortexproject/cortex/pkg/util"
)

// AllUsers returns true to each call and should be used whenever the UsersScanner should not filter out
Expand Down
3 changes: 2 additions & 1 deletion pkg/tracing/migration/bridge_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/weaveworks/common/httpgrpc"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"

"github.com/cortexproject/cortex/pkg/util/httpgrpcutil"
)
Expand All @@ -18,7 +19,7 @@ var (
spanID trace.SpanID = [8]byte{byte(11)}
traceIDKey = "Traceid"
spanIDKey = "Spanid"
noopTracer = trace.NewNoopTracerProvider().Tracer("")
noopTracer = noop.NewTracerProvider().Tracer("")
noopSpan = func() trace.Span {
_, s := noopTracer.Start(context.Background(), "")
return s
Expand Down

0 comments on commit b5f3690

Please sign in to comment.