From c3e03fdd650cc9fc9fb42ba10155d9ff96aeb9a5 Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Mon, 4 Dec 2023 14:31:25 -0500 Subject: [PATCH] even yet still more lint Signed-off-by: Owen Williams --- model/labels_test.go | 40 +++++++++++++++++++------------------- model/labelset_test.go | 2 +- model/metric.go | 21 ++++++++++---------- model/metric_test.go | 44 +++++++++++++++++++++--------------------- model/silence_test.go | 14 +++++++------- 5 files changed, 60 insertions(+), 61 deletions(-) diff --git a/model/labels_test.go b/model/labels_test.go index 4087dc71..80bf9269 100644 --- a/model/labels_test.go +++ b/model/labels_test.go @@ -92,54 +92,54 @@ func BenchmarkLabelValues(b *testing.B) { func TestLabelNameIsValid(t *testing.T) { var scenarios = []struct { - ln LabelName + ln LabelName legacyValid bool - utf8Valid bool + utf8Valid bool }{ { - ln: "Avalid_23name", + ln: "Avalid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - ln: "_Avalid_23name", + ln: "_Avalid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - ln: "1valid_23name", + ln: "1valid_23name", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - ln: "avalid_23name", + ln: "avalid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - ln: "Ava:lid_23name", + ln: "Ava:lid_23name", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - ln: "a lid_23name", + ln: "a lid_23name", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - ln: ":leading_colon", + ln: ":leading_colon", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - ln: "colon:in:the:middle", + ln: "colon:in:the:middle", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - ln: "a\xc5z", + ln: "a\xc5z", legacyValid: false, - utf8Valid: false, + utf8Valid: false, }, } diff --git a/model/labelset_test.go b/model/labelset_test.go index cfa70020..4d63f0b6 100644 --- a/model/labelset_test.go +++ b/model/labelset_test.go @@ -53,7 +53,7 @@ func TestUnmarshalJSONLabelSet(t *testing.T) { } }` - NameValidationScheme = LegacyValidation + NameValidationScheme = LegacyValidation err = json.Unmarshal([]byte(invalidlabelSetJSON), &c) expectedErr := `"1nvalid_23name" is not a valid label name` if err == nil || err.Error() != expectedErr { diff --git a/model/metric.go b/model/metric.go index 2e4c6a3c..a834f4b3 100644 --- a/model/metric.go +++ b/model/metric.go @@ -25,7 +25,7 @@ type validationSchemeId int const ( LegacyValidation = validationSchemeId(0) - UTF8Validation = validationSchemeId(1) + UTF8Validation = validationSchemeId(1) ) var ( @@ -103,15 +103,15 @@ func (m Metric) FastFingerprint() Fingerprint { // selected. func IsValidMetricName(n LabelValue) bool { switch NameValidationScheme { - case LegacyValidation: - return IsValidLegacyMetricName(n) - case UTF8Validation: - if len(n) == 0 { - return false - } - return utf8.ValidString(string(n)) - default: - panic(fmt.Sprintf("Invalid name validation scheme requested: %d", NameValidationScheme)) + case LegacyValidation: + return IsValidLegacyMetricName(n) + case UTF8Validation: + if len(n) == 0 { + return false + } + return utf8.ValidString(string(n)) + default: + panic(fmt.Sprintf("Invalid name validation scheme requested: %d", NameValidationScheme)) } } @@ -131,4 +131,3 @@ func IsValidLegacyMetricName(n LabelValue) bool { } return true } - diff --git a/model/metric_test.go b/model/metric_test.go index 0e2f9802..0beaeac1 100644 --- a/model/metric_test.go +++ b/model/metric_test.go @@ -84,59 +84,59 @@ func BenchmarkMetric(b *testing.B) { func TestMetricNameIsLegacyValid(t *testing.T) { var scenarios = []struct { - mn LabelValue + mn LabelValue legacyValid bool - utf8Valid bool + utf8Valid bool }{ { - mn: "Avalid_23name", + mn: "Avalid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - mn: "_Avalid_23name", + mn: "_Avalid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - mn: "1valid_23name", + mn: "1valid_23name", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - mn: "avalid_23name", + mn: "avalid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - mn: "Ava:lid_23name", + mn: "Ava:lid_23name", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - mn: "a lid_23name", + mn: "a lid_23name", legacyValid: false, - utf8Valid: true, + utf8Valid: true, }, { - mn: ":leading_colon", + mn: ":leading_colon", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - mn: "colon:in:the:middle", + mn: "colon:in:the:middle", legacyValid: true, - utf8Valid: true, + utf8Valid: true, }, { - mn: "", + mn: "", legacyValid: false, - utf8Valid: false, + utf8Valid: false, }, { - mn: "a\xc5z", + mn: "a\xc5z", legacyValid: false, - utf8Valid: false, + utf8Valid: false, }, } diff --git a/model/silence_test.go b/model/silence_test.go index 5b79f86d..d46afa47 100644 --- a/model/silence_test.go +++ b/model/silence_test.go @@ -21,9 +21,9 @@ import ( func TestMatcherValidate(t *testing.T) { var cases = []struct { - matcher *Matcher - legacyErr string - utf8Err string + matcher *Matcher + legacyErr string + utf8Err string }{ { matcher: &Matcher{ @@ -51,7 +51,7 @@ func TestMatcherValidate(t *testing.T) { Value: "value", }, legacyErr: "invalid name", - utf8Err: "invalid name", + utf8Err: "invalid name", }, { matcher: &Matcher{ @@ -59,7 +59,7 @@ func TestMatcherValidate(t *testing.T) { Value: "value\xff", }, legacyErr: "invalid value", - utf8Err: "invalid value", + utf8Err: "invalid value", }, { matcher: &Matcher{ @@ -67,7 +67,7 @@ func TestMatcherValidate(t *testing.T) { Value: "", }, legacyErr: "invalid value", - utf8Err: "invalid value", + utf8Err: "invalid value", }, { matcher: &Matcher{ @@ -75,7 +75,7 @@ func TestMatcherValidate(t *testing.T) { Value: "", }, legacyErr: "invalid name", - utf8Err: "invalid name", + utf8Err: "invalid name", }, }