Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
coanor committed Oct 12, 2023
1 parent 1ce3763 commit 0365be5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion promlinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"go/ast"
"go/token"
"log"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -149,7 +150,7 @@ func RunLint(fs *token.FileSet, files []*ast.File, s Setting) []Issue {
}

// lint metrics
for idx, mfp := range v.metrics {
for _, mfp := range v.metrics {
problems, err := promlint.NewWithMetricFamilies([]*dto.MetricFamily{mfp.MetricFamily}).Lint()
if err != nil {
panic(err)
Expand All @@ -174,6 +175,10 @@ func RunLint(fs *token.FileSet, files []*ast.File, s Setting) []Issue {
}
}

for _, iss := range v.issues {
log.Printf("%s, pos: %s", iss.Metric, iss.Pos)
}

sort.Slice(v.issues, func(i, j int) bool {
return v.issues[i].Pos.String() < v.issues[j].Pos.String()
})
Expand Down
2 changes: 1 addition & 1 deletion promlinter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestRun(t *testing.T) {
}

for idx, iss := range issues {
t.Logf("%d: %q", idx, iss)
t.Logf("%d: %q: %s", idx, iss.Metric, iss.Pos)

switch iss.Metric {
case "kube_daemonset_labels", "test_metric_name", "foo":
Expand Down

0 comments on commit 0365be5

Please sign in to comment.