Skip to content

Commit 31b0985

Browse files
committed
Update the lint metrics to match agains the rule URL rather than a prefix on the lint rule
Signed-off-by: Talon Bowler <[email protected]>
1 parent ab835fd commit 31b0985

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

util/progress/metricwriter.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,22 @@ func newLintMetricRecorder(meter metric.Meter, attrs attribute.Set) *lintMetricR
446446
return mr
447447
}
448448

449+
func kebabToCamel(s string) string {
450+
words := strings.Split(s, "-")
451+
for i, word := range words {
452+
words[i] = strings.Title(word)
453+
}
454+
return strings.Join(words, "")
455+
}
456+
449457
func (mr *lintMetricRecorder) Record(ss *client.SolveStatus) {
450458
for _, warning := range ss.Warnings {
451-
m := reLintMessage.FindSubmatch(warning.Short)
459+
m := reLintMessage.FindSubmatch([]byte(warning.URL))
452460
if m == nil {
453461
continue
454462
}
455463

456-
ruleName := string(m[1])
464+
ruleName := kebabToCamel(string(m[1]))
457465
mr.Count.Add(context.Background(), 1,
458466
metric.WithAttributeSet(mr.Attributes),
459467
metric.WithAttributes(
@@ -464,6 +472,6 @@ func (mr *lintMetricRecorder) Record(ss *client.SolveStatus) {
464472
}
465473

466474
var (
467-
reLintMessage = regexp.MustCompile(`^Lint Rule '(\w+)':`)
475+
reLintMessage = regexp.MustCompile(`^https://docs.docker.com/go/dockerfile/rule/([\w|-]+)/`)
468476
lintRuleNameProperty = attribute.Key("lint.rule.name")
469477
)

0 commit comments

Comments
 (0)