Skip to content

Commit 13ae064

Browse files
committed
address review comments
Signed-off-by: yeya24 <[email protected]>
1 parent 2b87ac5 commit 13ae064

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

.golangci.example.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,11 @@ linters-settings:
348348
range-loops: true # Report preallocation suggestions on range loops, true by default
349349
for-loops: false # Report preallocation suggestions on for loops, false by default
350350
promlinter:
351-
# Promlinter cannot infer all metrics name in static analysis. Enable strict mode
352-
# will also include the errors caused by failing to parse the args.
351+
# Promlinter cannot infer all metrics name in static analysis.
352+
# Enable strict mode will also include the errors caused by failing to parse the args.
353353
strict: false
354-
disabled-linters:
355354
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
355+
disabled-linters:
356356
# - "Help"
357357
# - "MetricUnits"
358358
# - "Counter"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ require (
8080
github.com/ultraware/whitespace v0.0.4
8181
github.com/uudashr/gocognit v1.0.1
8282
github.com/valyala/quicktemplate v1.6.3
83-
github.com/yeya24/promlinter v0.0.0-20210328235706-000c7d74ddb3
83+
github.com/yeya24/promlinter v0.1.0
8484
golang.org/x/tools v0.1.0
8585
gopkg.in/yaml.v2 v2.4.0
8686
honnef.co/go/tools v0.1.3

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/promlinter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ func NewPromlinter() *goanalysis.Linter {
7070
}
7171
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
7272
return resIssues
73-
}).WithLoadMode(goanalysis.LoadModeNone)
73+
}).WithLoadMode(goanalysis.LoadModeSyntax)
7474
}

pkg/lint/lintersdb/manager.go

+1
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
480480
WithPresets(linter.PresetStyle, linter.PresetModule).
481481
WithURL("https://github.com/ldez/gomoddirectives"),
482482
linter.NewConfig(golinters.NewPromlinter()).
483+
WithSince("v1.40.0").
483484
WithPresets(linter.PresetStyle).
484485
WithURL("https://github.com/yeya24/promlinter"),
485486
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives

test/testdata/promlinter.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ import (
88

99
var (
1010
_ = promauto.NewCounterVec(
11-
prometheus.CounterOpts{ // Metric: test_metric_name Error: counter metrics should have "_total" suffix
11+
prometheus.CounterOpts{ // ERROR `Metric: test_metric_name Error: counter metrics should have "_total" suffix`
1212
Name: "test_metric_name",
1313
Help: "test help text",
1414
}, []string{},
1515
)
1616

1717
_ = promauto.NewCounterVec(
18-
prometheus.CounterOpts{ // Metric: test_metric_total Error: no help text
18+
prometheus.CounterOpts{ // ERROR "Metric: test_metric_total Error: no help text"
1919
Name: "test_metric_total",
2020
}, []string{},
2121
)
2222

2323
_ = promauto.NewCounterVec(
24-
prometheus.CounterOpts{ // Metric: metric_type_in_name_counter_total Error: metric name should not include type 'counter'
24+
prometheus.CounterOpts{ // ERROR `Metric: metric_type_in_name_counter_total Error: metric name should not include type 'counter'`
2525
Name: "metric_type_in_name_counter_total",
2626
Help: "foo",
2727
}, []string{},
2828
)
2929

30-
_ = prometheus.NewHistogram(prometheus.HistogramOpts{ // Metric: test_duration_milliseconds Error: use base unit "seconds" instead of "milliseconds"
30+
_ = prometheus.NewHistogram(prometheus.HistogramOpts{ // ERROR `Metric: test_duration_milliseconds Error: use base unit "seconds" instead of "milliseconds"`
3131
Name: "test_duration_milliseconds",
3232
Help: "",
3333
})

0 commit comments

Comments
 (0)