Skip to content

Commit

Permalink
[chore]: enable usestdlibvars linter (#6001)
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]>
Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
mmorel-35 and MrAlias authored Nov 25, 2024
1 parent 446ee38 commit e98ef1b
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 118 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ linters:
- unconvert
- unused
- unparam
- usestdlibvars

issues:
# Maximum issues count per one linter.
Expand Down
8 changes: 4 additions & 4 deletions propagation/baggage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestExtractValidBaggageFromHTTPReq(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
req.Header.Set("baggage", tt.header)

ctx := context.Background()
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
req.Header.Set("baggage", tt.header)

expected := tt.has.Baggage(t)
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestInjectBaggageToHTTPReq(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
ctx := baggage.ContextWithBaggage(context.Background(), tt.mems.Baggage(t))
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))

Expand Down Expand Up @@ -273,7 +273,7 @@ func TestBaggageInjectExtractRoundtrip(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := tt.mems.Baggage(t)
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
ctx := baggage.ContextWithBaggage(context.Background(), b)
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))

Expand Down
6 changes: 3 additions & 3 deletions propagation/trace_context_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ func BenchmarkExtract(b *testing.B) {

func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) {
b.Run("Sampled", func(b *testing.B) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
req.Header.Set("traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
b.ReportAllocs()

fn(b, req)
})

b.Run("BogusVersion", func(b *testing.B) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
req.Header.Set("traceparent", "qw-00000000000000000000000000000000-0000000000000000-01")
b.ReportAllocs()
fn(b, req)
})

b.Run("FutureAdditionalData", func(b *testing.B) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil)
req.Header.Set("traceparent", "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-XYZxsf09")
b.ReportAllocs()
fn(b, req)
Expand Down
Loading

0 comments on commit e98ef1b

Please sign in to comment.