Skip to content

Commit 15ce6ee

Browse files
authored
Enable unconvert linter (#819)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
1 parent b775ce4 commit 15ce6ee

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ linters:
1919
- revive
2020
- sloglint
2121
- testifylint
22-
#- unconvert
22+
- unconvert
2323
- unused
2424
- usestdlibvars
2525
- whitespace

config/http_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var TLSVersions = map[string]TLSVersion{
7272

7373
func (tv *TLSVersion) UnmarshalYAML(unmarshal func(interface{}) error) error {
7474
var s string
75-
err := unmarshal((*string)(&s))
75+
err := unmarshal(&s)
7676
if err != nil {
7777
return err
7878
}
@@ -363,7 +363,7 @@ func (c *HTTPClientConfig) Validate() error {
363363
if (c.BasicAuth != nil || c.OAuth2 != nil) && (len(c.BearerToken) > 0 || len(c.BearerTokenFile) > 0) {
364364
return errors.New("at most one of basic_auth, oauth2, bearer_token & bearer_token_file must be configured")
365365
}
366-
if c.BasicAuth != nil && nonZeroCount(string(c.BasicAuth.Username) != "", c.BasicAuth.UsernameFile != "", c.BasicAuth.UsernameRef != "") > 1 {
366+
if c.BasicAuth != nil && nonZeroCount(c.BasicAuth.Username != "", c.BasicAuth.UsernameFile != "", c.BasicAuth.UsernameRef != "") > 1 {
367367
return errors.New("at most one of basic_auth username, username_file & username_ref must be configured")
368368
}
369369
if c.BasicAuth != nil && nonZeroCount(string(c.BasicAuth.Password) != "", c.BasicAuth.PasswordFile != "", c.BasicAuth.PasswordRef != "") > 1 {
@@ -1224,7 +1224,7 @@ func (c *TLSConfig) getClientCertificate(ctx context.Context, secretManager Secr
12241224
}
12251225
}
12261226

1227-
keySecret, err := toSecret(secretManager, Secret(c.Key), c.KeyFile, c.KeyRef)
1227+
keySecret, err := toSecret(secretManager, c.Key, c.KeyFile, c.KeyRef)
12281228
if err != nil {
12291229
return nil, fmt.Errorf("unable to use client key: %w", err)
12301230
}

model/metric_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func TestValidationScheme_IsMetricNameValid(t *testing.T) {
354354
if LegacyValidation.IsValidMetricName(s.mn) != s.legacyValid {
355355
t.Errorf("Expected %v for %q using LegacyValidation.IsValidMetricName", s.legacyValid, s.mn)
356356
}
357-
if MetricNameRE.MatchString(string(s.mn)) != s.legacyValid {
357+
if MetricNameRE.MatchString(s.mn) != s.legacyValid {
358358
t.Errorf("Expected %v for %q using regexp matching", s.legacyValid, s.mn)
359359
}
360360
if UTF8Validation.IsValidMetricName(s.mn) != s.utf8Valid {

model/time.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ func (t *Time) UnmarshalJSON(b []byte) error {
126126
p := strings.Split(string(b), ".")
127127
switch len(p) {
128128
case 1:
129-
v, err := strconv.ParseInt(string(p[0]), 10, 64)
129+
v, err := strconv.ParseInt(p[0], 10, 64)
130130
if err != nil {
131131
return err
132132
}
133133
*t = Time(v * second)
134134

135135
case 2:
136-
v, err := strconv.ParseInt(string(p[0]), 10, 64)
136+
v, err := strconv.ParseInt(p[0], 10, 64)
137137
if err != nil {
138138
return err
139139
}

model/value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (s Scalar) String() string {
258258
// MarshalJSON implements json.Marshaler.
259259
func (s Scalar) MarshalJSON() ([]byte, error) {
260260
v := strconv.FormatFloat(float64(s.Value), 'f', -1, 64)
261-
return json.Marshal([...]interface{}{s.Timestamp, string(v)})
261+
return json.Marshal([...]interface{}{s.Timestamp, v})
262262
}
263263

264264
// UnmarshalJSON implements json.Unmarshaler.

0 commit comments

Comments
 (0)