Skip to content

Commit ce9e5dd

Browse files
authored
apply v2.12.2 linter to codebase (#7495)
1 parent 2121261 commit ce9e5dd

5 files changed

Lines changed: 36 additions & 46 deletions

File tree

‎.github/workflows/test-build-deploy.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
lint:
1818
runs-on: ubuntu-24.04
1919
container:
20-
image: quay.io/cortexproject/build-image:master-ee0b97cc37
20+
image: quay.io/cortexproject/build-image:master-5f643d518c
2121
steps:
2222
- name: Checkout Repo
2323
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -53,7 +53,7 @@ jobs:
5353
name: test (${{ matrix.name }})
5454
runs-on: ${{ matrix.runner }}
5555
container:
56-
image: quay.io/cortexproject/build-image:master-ee0b97cc37
56+
image: quay.io/cortexproject/build-image:master-5f643d518c
5757
steps:
5858
- name: Checkout Repo
5959
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -81,7 +81,7 @@ jobs:
8181
name: test-no-race (${{ matrix.name }})
8282
runs-on: ${{ matrix.runner }}
8383
container:
84-
image: quay.io/cortexproject/build-image:master-ee0b97cc37
84+
image: quay.io/cortexproject/build-image:master-5f643d518c
8585
steps:
8686
- name: Checkout Repo
8787
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -125,7 +125,7 @@ jobs:
125125
build:
126126
runs-on: ubuntu-24.04
127127
container:
128-
image: quay.io/cortexproject/build-image:master-ee0b97cc37
128+
image: quay.io/cortexproject/build-image:master-5f643d518c
129129
steps:
130130
- name: Checkout Repo
131131
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -318,14 +318,14 @@ jobs:
318318
touch build-image/.uptodate
319319
MIGRATIONS_DIR=$(pwd)/cmd/cortex/migrations
320320
echo "Running configs integration tests on ${{ matrix.arch }}"
321-
make BUILD_IMAGE=quay.io/cortexproject/build-image:master-ee0b97cc37 TTY='' configs-integration-test
321+
make BUILD_IMAGE=quay.io/cortexproject/build-image:master-5f643d518c TTY='' configs-integration-test
322322
323323
deploy:
324324
needs: [build, test, lint, integration, integration-configs-db]
325325
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex'
326326
runs-on: ubuntu-24.04
327327
container:
328-
image: quay.io/cortexproject/build-image:master-ee0b97cc37
328+
image: quay.io/cortexproject/build-image:master-5f643d518c
329329
steps:
330330
- name: Checkout Repo
331331
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

‎pkg/alertmanager/api.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func validateAlertmanagerConfig(cfg any) error {
385385

386386
// If the input config is a pointer then we need to get its value.
387387
// At this point the pointer value can't be nil.
388-
if v.Kind() == reflect.Ptr {
388+
if v.Kind() == reflect.Pointer {
389389
v = v.Elem()
390390
t = v.Type()
391391
}

‎pkg/cortex/modules_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func TestConfig_SensitiveFieldTypes(t *testing.T) {
305305
// checkSensitiveFields recursively walks a type and reports any string field
306306
// whose YAML tag matches the sensitive pattern.
307307
func checkSensitiveFields(t reflect.Type, prefix string, pattern *regexp.Regexp, secretType reflect.Type, violations *[]string) {
308-
if t.Kind() == reflect.Ptr {
308+
if t.Kind() == reflect.Pointer {
309309
t = t.Elem()
310310
}
311311
if t.Kind() != reflect.Struct {
@@ -322,7 +322,7 @@ func checkSensitiveFields(t reflect.Type, prefix string, pattern *regexp.Regexp,
322322
}
323323

324324
ft := f.Type
325-
if ft.Kind() == reflect.Ptr {
325+
if ft.Kind() == reflect.Pointer {
326326
ft = ft.Elem()
327327
}
328328
if ft.Kind() == reflect.Struct && ft != secretType {
@@ -335,7 +335,7 @@ func checkSensitiveFields(t reflect.Type, prefix string, pattern *regexp.Regexp,
335335
// field's Value to the given sentinel string.
336336
func setAllSecrets(v reflect.Value, sentinel string) {
337337
switch v.Kind() {
338-
case reflect.Ptr:
338+
case reflect.Pointer:
339339
if !v.IsNil() {
340340
setAllSecrets(v.Elem(), sentinel)
341341
}

‎pkg/util/metrics_helper_test.go‎

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ func TestSendSumOfHistogramsWithLabels(t *testing.T) {
266266
mf.SendSumOfHistogramsWithLabels(out, desc, "test_metric", "label_one")
267267
})
268268
expected := []*dto.Metric{
269-
{Label: makeLabels("label_one", "a"), Histogram: &dto.Histogram{SampleCount: uint64p(4), SampleSum: float64p(10), Bucket: []*dto.Bucket{
270-
{UpperBound: float64p(1), CumulativeCount: uint64p(1)},
271-
{UpperBound: float64p(2), CumulativeCount: uint64p(2)},
272-
{UpperBound: float64p(3), CumulativeCount: uint64p(3)},
269+
{Label: makeLabels("label_one", "a"), Histogram: &dto.Histogram{SampleCount: new(uint64(4)), SampleSum: new(float64(10)), Bucket: []*dto.Bucket{
270+
{UpperBound: new(float64(1)), CumulativeCount: new(uint64(1))},
271+
{UpperBound: new(float64(2)), CumulativeCount: new(uint64(2))},
272+
{UpperBound: new(float64(3)), CumulativeCount: new(uint64(3))},
273273
}}},
274274
}
275275
require.ElementsMatch(t, expected, actual)
@@ -281,15 +281,15 @@ func TestSendSumOfHistogramsWithLabels(t *testing.T) {
281281
mf.SendSumOfHistogramsWithLabels(out, desc, "test_metric", "label_two")
282282
})
283283
expected := []*dto.Metric{
284-
{Label: makeLabels("label_two", "b"), Histogram: &dto.Histogram{SampleCount: uint64p(2), SampleSum: float64p(4), Bucket: []*dto.Bucket{
285-
{UpperBound: float64p(1), CumulativeCount: uint64p(1)},
286-
{UpperBound: float64p(2), CumulativeCount: uint64p(1)},
287-
{UpperBound: float64p(3), CumulativeCount: uint64p(2)},
284+
{Label: makeLabels("label_two", "b"), Histogram: &dto.Histogram{SampleCount: new(uint64(2)), SampleSum: new(float64(4)), Bucket: []*dto.Bucket{
285+
{UpperBound: new(float64(1)), CumulativeCount: new(uint64(1))},
286+
{UpperBound: new(float64(2)), CumulativeCount: new(uint64(1))},
287+
{UpperBound: new(float64(3)), CumulativeCount: new(uint64(2))},
288288
}}},
289-
{Label: makeLabels("label_two", "c"), Histogram: &dto.Histogram{SampleCount: uint64p(2), SampleSum: float64p(6), Bucket: []*dto.Bucket{
290-
{UpperBound: float64p(1), CumulativeCount: uint64p(0)},
291-
{UpperBound: float64p(2), CumulativeCount: uint64p(1)},
292-
{UpperBound: float64p(3), CumulativeCount: uint64p(1)},
289+
{Label: makeLabels("label_two", "c"), Histogram: &dto.Histogram{SampleCount: new(uint64(2)), SampleSum: new(float64(6)), Bucket: []*dto.Bucket{
290+
{UpperBound: new(float64(1)), CumulativeCount: new(uint64(0))},
291+
{UpperBound: new(float64(2)), CumulativeCount: new(uint64(1))},
292+
{UpperBound: new(float64(3)), CumulativeCount: new(uint64(1))},
293293
}}},
294294
}
295295
require.ElementsMatch(t, expected, actual)
@@ -301,15 +301,15 @@ func TestSendSumOfHistogramsWithLabels(t *testing.T) {
301301
mf.SendSumOfHistogramsWithLabels(out, desc, "test_metric", "label_one", "label_two")
302302
})
303303
expected := []*dto.Metric{
304-
{Label: makeLabels("label_one", "a", "label_two", "b"), Histogram: &dto.Histogram{SampleCount: uint64p(2), SampleSum: float64p(4), Bucket: []*dto.Bucket{
305-
{UpperBound: float64p(1), CumulativeCount: uint64p(1)},
306-
{UpperBound: float64p(2), CumulativeCount: uint64p(1)},
307-
{UpperBound: float64p(3), CumulativeCount: uint64p(2)},
304+
{Label: makeLabels("label_one", "a", "label_two", "b"), Histogram: &dto.Histogram{SampleCount: new(uint64(2)), SampleSum: new(float64(4)), Bucket: []*dto.Bucket{
305+
{UpperBound: new(float64(1)), CumulativeCount: new(uint64(1))},
306+
{UpperBound: new(float64(2)), CumulativeCount: new(uint64(1))},
307+
{UpperBound: new(float64(3)), CumulativeCount: new(uint64(2))},
308308
}}},
309-
{Label: makeLabels("label_one", "a", "label_two", "c"), Histogram: &dto.Histogram{SampleCount: uint64p(2), SampleSum: float64p(6), Bucket: []*dto.Bucket{
310-
{UpperBound: float64p(1), CumulativeCount: uint64p(0)},
311-
{UpperBound: float64p(2), CumulativeCount: uint64p(1)},
312-
{UpperBound: float64p(3), CumulativeCount: uint64p(1)},
309+
{Label: makeLabels("label_one", "a", "label_two", "c"), Histogram: &dto.Histogram{SampleCount: new(uint64(2)), SampleSum: new(float64(6)), Bucket: []*dto.Bucket{
310+
{UpperBound: new(float64(1)), CumulativeCount: new(uint64(0))},
311+
{UpperBound: new(float64(2)), CumulativeCount: new(uint64(1))},
312+
{UpperBound: new(float64(3)), CumulativeCount: new(uint64(1))},
313313
}}},
314314
}
315315
require.ElementsMatch(t, expected, actual)
@@ -407,8 +407,8 @@ func TestSendSumOfSummariesPerUser(t *testing.T) {
407407
{
408408
Label: makeLabels("user", "user-1"),
409409
Summary: &dto.Summary{
410-
SampleCount: uint64p(3),
411-
SampleSum: float64p(150),
410+
SampleCount: new(uint64(3)),
411+
SampleSum: new(float64(150)),
412412
Quantile: []*dto.Quantile{
413413
{
414414
Quantile: new(.25),
@@ -428,8 +428,8 @@ func TestSendSumOfSummariesPerUser(t *testing.T) {
428428
{
429429
Label: makeLabels("user", "user-2"),
430430
Summary: &dto.Summary{
431-
SampleCount: uint64p(3),
432-
SampleSum: float64p(151),
431+
SampleCount: new(uint64(3)),
432+
SampleSum: new(float64(151)),
433433
Quantile: []*dto.Quantile{
434434
{
435435
Quantile: new(.25),
@@ -1109,16 +1109,6 @@ func collectMetrics(t *testing.T, send func(out chan prometheus.Metric)) []*dto.
11091109
return metrics
11101110
}
11111111

1112-
//go:fix inline
1113-
func float64p(v float64) *float64 {
1114-
return new(v)
1115-
}
1116-
1117-
//go:fix inline
1118-
func uint64p(v uint64) *uint64 {
1119-
return new(v)
1120-
}
1121-
11221112
func BenchmarkGetLabels_SmallSet(b *testing.B) {
11231113
m := prometheus.NewCounterVec(prometheus.CounterOpts{
11241114
Name: "test",

‎tools/doc-generator/parser.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ func parseConfig(block *configBlock, cfg any, flags map[uintptr]*flag.Flag, adde
8383
}
8484

8585
// The input config is expected to be addressable.
86-
if reflect.TypeOf(cfg).Kind() != reflect.Ptr {
86+
if reflect.TypeOf(cfg).Kind() != reflect.Pointer {
8787
t := reflect.TypeOf(cfg)
88-
return nil, fmt.Errorf("%s is a %s while a %s is expected", t, t.Kind(), reflect.Ptr)
88+
return nil, fmt.Errorf("%s is a %s while a %s is expected", t, t.Kind(), reflect.Pointer)
8989
}
9090

9191
// The input config is expected to be a pointer to struct.

0 commit comments

Comments
 (0)