diff --git a/cmd/cortextool/main.go b/cmd/cortextool/main.go index abc82569d..111f98269 100644 --- a/cmd/cortextool/main.go +++ b/cmd/cortextool/main.go @@ -38,7 +38,7 @@ func main() { analyseCommand.Register(app) bucketValidateCommand.Register(app) - app.Command("version", "Get the version of the cortextool CLI").Action(func(k *kingpin.ParseContext) error { + app.Command("version", "Get the version of the cortextool CLI").Action(func(_ *kingpin.ParseContext) error { fmt.Print(version.Template) version.CheckLatest() diff --git a/cmd/rules-migrator/main.go b/cmd/rules-migrator/main.go index 40006915b..d99fa8c84 100644 --- a/cmd/rules-migrator/main.go +++ b/cmd/rules-migrator/main.go @@ -6,7 +6,7 @@ import ( "encoding/base64" "flag" "fmt" - "io/ioutil" + "io" "log" "strings" @@ -75,7 +75,7 @@ func main() { log.Fatalf("unable to load object, %v", err) } - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { log.Fatalf("unable to read object, %v", err) } diff --git a/pkg/analyse/grafana.go b/pkg/analyse/grafana.go index 780189e25..83e9d1529 100644 --- a/pkg/analyse/grafana.go +++ b/pkg/analyse/grafana.go @@ -153,7 +153,7 @@ func parseQuery(query string, metrics map[string]struct{}) error { return err } - parser.Inspect(expr, func(node parser.Node, path []parser.Node) error { + parser.Inspect(expr, func(node parser.Node, _ []parser.Node) error { if n, ok := node.(*parser.VectorSelector); ok { metrics[n.Name] = struct{}{} } diff --git a/pkg/analyse/ruler.go b/pkg/analyse/ruler.go index 9fe3d192a..7ea4c9a1b 100644 --- a/pkg/analyse/ruler.go +++ b/pkg/analyse/ruler.go @@ -43,7 +43,7 @@ func ParseMetricsInRuleGroup(mir *MetricsInRuler, group rwrulefmt.RuleGroup, ns continue } - parser.Inspect(expr, func(node parser.Node, path []parser.Node) error { + parser.Inspect(expr, func(node parser.Node, _ []parser.Node) error { if n, ok := node.(*parser.VectorSelector); ok { refMetrics[n.Name] = struct{}{} } diff --git a/pkg/chunk/gcp/gcs_scanner.go b/pkg/chunk/gcp/gcs_scanner.go index cbb685fc1..d59eaaaf1 100644 --- a/pkg/chunk/gcp/gcs_scanner.go +++ b/pkg/chunk/gcp/gcs_scanner.go @@ -1,15 +1,16 @@ package gcp import ( - "cloud.google.com/go/storage" "context" "fmt" + "io" + + "cloud.google.com/go/storage" "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/gcp" "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/api/iterator" - "io" chunkTool "github.com/cortexproject/cortex-tools/pkg/chunk" ) diff --git a/pkg/chunk/migrate/reader/reader.go b/pkg/chunk/migrate/reader/reader.go index 894655a07..001160e43 100644 --- a/pkg/chunk/migrate/reader/reader.go +++ b/pkg/chunk/migrate/reader/reader.go @@ -140,7 +140,7 @@ func (r *Reader) readLoop(ctx context.Context, outChan chan cortex_chunk.Chunk, "shard": req.Prefix}) logEntry.Infoln("attempting scan request") - err := r.scanner.Scan(ctx, req, func(i cortex_chunk.Chunk) bool { + err := r.scanner.Scan(ctx, req, func(_ cortex_chunk.Chunk) bool { // while this does not mean chunk is sent by scanner, this is the closest we can get SentChunks.Inc() return true diff --git a/pkg/client/alerts.go b/pkg/client/alerts.go index 4da7352c4..e7a9e9a77 100644 --- a/pkg/client/alerts.go +++ b/pkg/client/alerts.go @@ -2,10 +2,11 @@ package client import ( "context" + "io" + "github.com/pkg/errors" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v3" - "io" ) const alertmanagerAPIPath = "/api/v1/alerts" diff --git a/pkg/client/rules_test.go b/pkg/client/rules_test.go index a42034cb9..c3dab26e0 100644 --- a/pkg/client/rules_test.go +++ b/pkg/client/rules_test.go @@ -12,7 +12,7 @@ import ( func TestCortexClient_DeleteRuleGroup(t *testing.T) { requestCh := make(chan *http.Request, 1) - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { requestCh <- r })) defer ts.Close() @@ -76,7 +76,7 @@ func TestCortexClient_DeleteRuleGroup(t *testing.T) { func TestCortexClient_DeleteRuleNamespace(t *testing.T) { requestCh := make(chan *http.Request, 1) - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { requestCh <- r })) defer ts.Close() diff --git a/pkg/commands/rules.go b/pkg/commands/rules.go index 21fc0db1a..3521d0f0e 100644 --- a/pkg/commands/rules.go +++ b/pkg/commands/rules.go @@ -642,7 +642,7 @@ func (r *RuleCommand) prepare(_ *kingpin.ParseContext) error { } // Do not apply the aggregation label to excluded rule groups. - applyTo := func(group rwrulefmt.RuleGroup, rule rulefmt.RuleNode) bool { + applyTo := func(group rwrulefmt.RuleGroup, _ rulefmt.RuleNode) bool { _, excluded := r.aggregationLabelExcludedRuleGroupsList[group.Name] return !excluded } diff --git a/pkg/rules/rules.go b/pkg/rules/rules.go index 8e9bd6b37..fd68d3a78 100644 --- a/pkg/rules/rules.go +++ b/pkg/rules/rules.go @@ -143,7 +143,7 @@ func (r RuleNamespace) AggregateBy(label string, applyTo func(group rwrulefmt.Ru // exprNodeInspectorFunc returns a PromQL inspector. // It modifies most PromQL expressions to include a given label. func exprNodeInspectorFunc(rule rulefmt.RuleNode, label string) func(node parser.Node, path []parser.Node) error { - return func(node parser.Node, path []parser.Node) error { + return func(node parser.Node, _ []parser.Node) error { var err error switch n := node.(type) { case *parser.AggregateExpr: diff --git a/pkg/rules/rules_test.go b/pkg/rules/rules_test.go index 0b5287279..9b4aa7c04 100644 --- a/pkg/rules/rules_test.go +++ b/pkg/rules/rules_test.go @@ -176,7 +176,7 @@ func TestAggregateBy(t *testing.T) { }, }, }, - applyTo: func(group rwrulefmt.RuleGroup, rule rulefmt.RuleNode) bool { + applyTo: func(group rwrulefmt.RuleGroup, _ rulefmt.RuleNode) bool { return group.Name != "CountSkipped" }, expectedExpr: []string{`count by(namespace, cluster) (test_series) > 1`, `count by(namespace) (test_series) > 1`},