Skip to content

Commit 2f532ba

Browse files
committed
Merge remote-tracking branch 'origin/main' into arve/gocritic
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2 parents a65f6d7 + 15ce6ee commit 2f532ba

12 files changed

Lines changed: 32 additions & 34 deletions

File tree

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ linters:
77
- exptostd
88
#- fatcontext
99
- gocritic
10-
#- godot
10+
- godot
1111
- govet
1212
- loggercheck
1313
- misspell
@@ -19,9 +19,9 @@ linters:
1919
- revive
2020
- sloglint
2121
- testifylint
22-
#- unconvert
22+
- unconvert
2323
- unused
24-
#- usestdlibvars
24+
- usestdlibvars
2525
- whitespace
2626
exclusions:
2727
generated: lax

config/http_config.go

Lines changed: 5 additions & 5 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
}
@@ -245,7 +245,7 @@ type OAuth2 struct {
245245
ProxyConfig `yaml:",inline"`
246246
}
247247

248-
// UnmarshalYAML implements the yaml.Unmarshaler interface
248+
// UnmarshalYAML implements the yaml.Unmarshaler interface.
249249
func (o *OAuth2) UnmarshalYAML(unmarshal func(interface{}) error) error {
250250
type plain OAuth2
251251
if err := unmarshal((*plain)(o)); err != nil {
@@ -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 {
@@ -423,7 +423,7 @@ func (c *HTTPClientConfig) Validate() error {
423423
return nil
424424
}
425425

426-
// UnmarshalYAML implements the yaml.Unmarshaler interface
426+
// UnmarshalYAML implements the yaml.Unmarshaler interface.
427427
func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
428428
type plain HTTPClientConfig
429429
*c = DefaultHTTPClientConfig
@@ -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
}

config/http_config_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ func TestBearerAuthRoundTripper(t *testing.T) {
706706

707707
// Normal flow.
708708
bearerAuthRoundTripper := NewAuthorizationCredentialsRoundTripper("Bearer", NewInlineSecret(BearerToken), fakeRoundTripper)
709-
request, _ := http.NewRequest("GET", "/hitchhiker", nil)
709+
request, _ := http.NewRequest(http.MethodGet, "/hitchhiker", nil)
710710
request.Header.Set("User-Agent", "Douglas Adams mind")
711711
_, err := bearerAuthRoundTripper.RoundTrip(request)
712712
if err != nil {
@@ -715,7 +715,7 @@ func TestBearerAuthRoundTripper(t *testing.T) {
715715

716716
// Should honor already Authorization header set.
717717
bearerAuthRoundTripperShouldNotModifyExistingAuthorization := NewAuthorizationCredentialsRoundTripper("Bearer", NewInlineSecret(newBearerToken), fakeRoundTripper)
718-
request, _ = http.NewRequest("GET", "/hitchhiker", nil)
718+
request, _ = http.NewRequest(http.MethodGet, "/hitchhiker", nil)
719719
request.Header.Set("Authorization", ExpectedBearer)
720720
_, err = bearerAuthRoundTripperShouldNotModifyExistingAuthorization.RoundTrip(request)
721721
if err != nil {
@@ -734,7 +734,7 @@ func TestBearerAuthFileRoundTripper(t *testing.T) {
734734

735735
// Normal flow.
736736
bearerAuthRoundTripper := NewAuthorizationCredentialsRoundTripper("Bearer", &FileSecret{file: BearerTokenFile}, fakeRoundTripper)
737-
request, _ := http.NewRequest("GET", "/hitchhiker", nil)
737+
request, _ := http.NewRequest(http.MethodGet, "/hitchhiker", nil)
738738
request.Header.Set("User-Agent", "Douglas Adams mind")
739739
_, err := bearerAuthRoundTripper.RoundTrip(request)
740740
if err != nil {
@@ -743,7 +743,7 @@ func TestBearerAuthFileRoundTripper(t *testing.T) {
743743

744744
// Should honor already Authorization header set.
745745
bearerAuthRoundTripperShouldNotModifyExistingAuthorization := NewAuthorizationCredentialsRoundTripper("Bearer", &FileSecret{file: MissingBearerTokenFile}, fakeRoundTripper)
746-
request, _ = http.NewRequest("GET", "/hitchhiker", nil)
746+
request, _ = http.NewRequest(http.MethodGet, "/hitchhiker", nil)
747747
request.Header.Set("Authorization", ExpectedBearer)
748748
_, err = bearerAuthRoundTripperShouldNotModifyExistingAuthorization.RoundTrip(request)
749749
if err != nil {
@@ -1749,7 +1749,7 @@ func TestUnmarshalEmptyURL(t *testing.T) {
17491749
}
17501750
}
17511751

1752-
// checks if u equals to &url.URL{}
1752+
// checks if u equals to &url.URL{}.
17531753
func isEmptyNonNilURL(u *url.URL) bool {
17541754
return u != nil && *u == url.URL{}
17551755
}
@@ -2105,7 +2105,7 @@ no_proxy: promcon.io,cncf.io`, proxyServer.URL),
21052105
os.Setenv("NO_PROXY", tc.noProxyEnv)
21062106
}
21072107

2108-
req := httptest.NewRequest("GET", tc.targetURL, nil)
2108+
req := httptest.NewRequest(http.MethodGet, tc.targetURL, nil)
21092109

21102110
proxyFunc := proxyConfig.Proxy()
21112111
resultURL, err := proxyFunc(req)

expfmt/expfmt_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import (
2121
"github.com/prometheus/common/model"
2222
)
2323

24-
// Test Format to Escapting Scheme conversion
25-
// Path: expfmt/expfmt_test.go
26-
// Compare this snippet from expfmt/expfmt.go:
24+
// Test Format to Escaping Scheme conversion.
2725
func TestToFormatType(t *testing.T) {
2826
tests := []struct {
2927
format Format

model/metric.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ const (
238238
// Accept header, the default NameEscapingScheme will be used.
239239
EscapingKey = "escaping"
240240

241-
// Possible values for Escaping Key:
241+
// Possible values for Escaping Key.
242242
AllowUTF8 = "allow-utf-8" // No escaping required.
243243
EscapeUnderscores = "underscores"
244244
EscapeDots = "dots"
@@ -472,7 +472,7 @@ func EscapeName(name string, scheme EscapingScheme) string {
472472
}
473473
}
474474

475-
// lower function taken from strconv.atoi
475+
// lower function taken from strconv.atoi.
476476
func lower(c byte) byte {
477477
return c | ('x' - 'X')
478478
}

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: 4 additions & 4 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
}
@@ -170,14 +170,14 @@ func (t *Time) UnmarshalJSON(b []byte) error {
170170
// This type should not propagate beyond the scope of input/output processing.
171171
type Duration time.Duration
172172

173-
// Set implements pflag/flag.Value
173+
// Set implements pflag/flag.Value.
174174
func (d *Duration) Set(s string) error {
175175
var err error
176176
*d, err = ParseDuration(s)
177177
return err
178178
}
179179

180-
// Type implements pflag.Value
180+
// Type implements pflag.Value.
181181
func (d *Duration) Type() string {
182182
return "duration"
183183
}

model/value.go

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

265265
// UnmarshalJSON implements json.Unmarshaler.

promslog/flag/flag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const FormatFlagName = "log.format"
4040
var FormatFlagHelp = "Output format of log messages. One of: [" + strings.Join(promslog.FormatFlagOptions, ", ") + "]"
4141

4242
// AddFlags adds the flags used by this package to the Kingpin application.
43-
// To use the default Kingpin application, call AddFlags(kingpin.CommandLine)
43+
// To use the default Kingpin application, call AddFlags(kingpin.CommandLine).
4444
func AddFlags(a *kingpin.Application, config *promslog.Config) {
4545
config.Level = promslog.NewLevel()
4646
a.Flag(LevelFlagName, LevelFlagHelp).

promslog/slog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (f *Format) Set(s string) error {
138138
return nil
139139
}
140140

141-
// Config is a struct containing configurable settings for the logger
141+
// Config is a struct containing configurable settings for the logger.
142142
type Config struct {
143143
Level *Level
144144
Format *Format

0 commit comments

Comments
 (0)