Skip to content

Commit

Permalink
[chore]: enable usestdlibvars linter (#11541)
Browse files Browse the repository at this point in the history
#### Description

[usestdlibvars](https://golangci-lint.run/usage/linters/#usestdlibvars)
is a linter that detect the possibility to use variables/constants from
the Go standard library.

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Oct 27, 2024
1 parent b6d0497 commit 7f6dc01
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ linters:
- unconvert
- unused
- unparam
- usestdlibvars

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
Expand Down
6 changes: 3 additions & 3 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ func TestServerAuth(t *testing.T) {
require.NoError(t, err)

// tt
srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest("GET", "/", nil))
srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest(http.MethodGet, "/", nil))

// verify
assert.True(t, handlerCalled)
Expand Down Expand Up @@ -1215,7 +1215,7 @@ func TestFailedServerAuth(t *testing.T) {

// tt
response := &httptest.ResponseRecorder{}
srv.Handler.ServeHTTP(response, httptest.NewRequest("GET", "/", nil))
srv.Handler.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/", nil))

// verify
assert.Equal(t, http.StatusUnauthorized, response.Result().StatusCode)
Expand Down Expand Up @@ -1404,7 +1404,7 @@ func TestAuthWithQueryParams(t *testing.T) {
require.NoError(t, err)

// tt
srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest("GET", "/?auth=1", nil))
srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest(http.MethodGet, "/?auth=1", nil))

// verify
assert.True(t, handlerCalled)
Expand Down
18 changes: 9 additions & 9 deletions exporter/otlphttpexporter/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func TestErrorResponses(t *testing.T) {

func TestErrorResponseInvalidResponseBody(t *testing.T) {
resp := &http.Response{
StatusCode: 400,
StatusCode: http.StatusBadRequest,
Body: io.NopCloser(badReader{}),
ContentLength: 100,
}
Expand Down Expand Up @@ -294,7 +294,7 @@ func TestUserAgent(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
srv := createBackend("/v1/traces", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("user-agent"), tt.expectedUA)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -328,7 +328,7 @@ func TestUserAgent(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
srv := createBackend("/v1/metrics", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("user-agent"), tt.expectedUA)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -362,7 +362,7 @@ func TestUserAgent(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
srv := createBackend("/v1/logs", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("user-agent"), tt.expectedUA)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -398,7 +398,7 @@ func TestUserAgent(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
srv := createBackend("/v1development/profiles", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("user-agent"), test.expectedUA)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -1013,7 +1013,7 @@ func TestEncoding(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
srv := createBackend("/v1/traces", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("content-type"), tt.expectedEncoding)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -1044,7 +1044,7 @@ func TestEncoding(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
srv := createBackend("/v1/metrics", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("content-type"), tt.expectedEncoding)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -1075,7 +1075,7 @@ func TestEncoding(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
srv := createBackend("/v1/logs", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("content-type"), tt.expectedEncoding)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down Expand Up @@ -1108,7 +1108,7 @@ func TestEncoding(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
srv := createBackend("/v1development/profiles", func(writer http.ResponseWriter, request *http.Request) {
assert.Contains(t, request.Header.Get("content-type"), test.expectedEncoding)
writer.WriteHeader(200)
writer.WriteHeader(http.StatusOK)
})
defer srv.Close()

Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

func FuzzReceiverHandlers(f *testing.F) {
f.Fuzz(func(_ *testing.T, data []byte, pb bool, handler int) {
req, err := http.NewRequest("POST", "", bytes.NewReader(data))
req, err := http.NewRequest(http.MethodPost, "", bytes.NewReader(data))
if err != nil {
return
}
Expand Down

0 comments on commit 7f6dc01

Please sign in to comment.