Skip to content

Commit

Permalink
[chore]: enable usestdlibvars linter
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Nov 24, 2024
1 parent 73c4165 commit 0dcfc10
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
run:
issues-exit-code: 1 #Default
tests: true #Default
timeout: 2m
timeout: 5m

linters:
# Disable everything by default so upgrades to not include new "default
Expand Down Expand Up @@ -32,6 +32,7 @@ linters:
- unconvert
- unparam
- unused
- usestdlibvars

issues:
# Maximum issues count per one linter.
Expand Down Expand Up @@ -68,6 +69,7 @@ issues:
linters:
- gosec
- perfsprint
- usestdlibvars
include:
# revive exported should have comment or be unexported.
- EXC0012
Expand Down
2 changes: 1 addition & 1 deletion detectors/azure/azurevm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (detector *ResourceDetector) getJSONMetadata(ctx context.Context) ([]byte,

client := http.Client{Transport: pTransport}

req, err := http.NewRequestWithContext(ctx, "GET", detector.endpoint, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, detector.endpoint, nil)
if err != nil {
return nil, false, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main() {
ctx, span := tr.Start(ctx, "say hello", trace.WithAttributes(semconv.PeerService("ExampleService")))
defer span.End()

req, _ := http.NewRequestWithContext(ctx, "GET", *url, nil)
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, *url, nil)

Check warning on line 82 in instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go#L82

Added line #L82 was not covered by tests

fmt.Printf("Sending request...\n")
res, err := client.Do(req)
Expand Down
6 changes: 3 additions & 3 deletions instrumentation/net/http/otelhttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)}

// Get is a convenient replacement for http.Get that adds a span around the request.
func Get(ctx context.Context, targetURL string) (resp *http.Response, err error) {
req, err := http.NewRequestWithContext(ctx, "GET", targetURL, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, targetURL, nil)
if err != nil {
return nil, err
}
Expand All @@ -27,7 +27,7 @@ func Get(ctx context.Context, targetURL string) (resp *http.Response, err error)

// Head is a convenient replacement for http.Head that adds a span around the request.
func Head(ctx context.Context, targetURL string) (resp *http.Response, err error) {
req, err := http.NewRequestWithContext(ctx, "HEAD", targetURL, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodHead, targetURL, nil)
if err != nil {
return nil, err
}
Expand All @@ -36,7 +36,7 @@ func Head(ctx context.Context, targetURL string) (resp *http.Response, err error

// Post is a convenient replacement for http.Post that adds a span around the request.
func Post(ctx context.Context, targetURL, contentType string, body io.Reader) (resp *http.Response, err error) {
req, err := http.NewRequestWithContext(ctx, "POST", targetURL, body)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, targetURL, body)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/example/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
err = func(ctx context.Context) error {
ctx, span := tr.Start(ctx, "say hello", trace.WithAttributes(semconv.PeerService("ExampleService")))
defer span.End()
req, _ := http.NewRequestWithContext(ctx, "GET", *url, nil)
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, *url, nil)

Check warning on line 69 in instrumentation/net/http/otelhttp/example/client/client.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/net/http/otelhttp/example/client/client.go#L69

Added line #L69 was not covered by tests

fmt.Printf("Sending request...\n")
res, err := client.Do(req)
Expand Down

0 comments on commit 0dcfc10

Please sign in to comment.