Skip to content

Commit

Permalink
Ignore the false-positive
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Dec 14, 2024
1 parent 0078924 commit e5979a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions detectors/azure/azurevm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ func (detector *ResourceDetector) getJSONMetadata(ctx context.Context) ([]byte,

req.Header.Add("Metadata", "True")

resp, err := client.Do(req)
resp, err := client.Do(req) // nolint:bodyclose // False-positive.
if err != nil {
return nil, false, err
}

defer resp.Body.Close()

if resp.StatusCode == http.StatusOK {
Expand Down
15 changes: 8 additions & 7 deletions instrumentation/net/http/otelhttp/test/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ func TestTransportUsesFormatter(t *testing.T) {
)

c := http.Client{Transport: tr}
res, err := c.Do(r)
if err != nil {
t.Fatal(err)
}
res, err := c.Do(r) // nolint:bodyclose // False-positive.
require.NoError(t, err)
require.NoError(t, res.Body.Close())

spans := spanRecorder.Ended()
Expand Down Expand Up @@ -99,10 +97,10 @@ func TestTransportErrorStatus(t *testing.T) {
if err != nil {
t.Fatal(err)
}
resp, err := c.Do(r)
resp, err := c.Do(r) // nolint:bodyclose // False-positive.
if err == nil {
if err := resp.Body.Close(); err != nil {
t.Errorf("close response body: %v", err)
if e := resp.Body.Close(); e != nil {
t.Errorf("close response body: %v", e)
}
t.Fatal("transport should have returned an error, it didn't")
}
Expand Down Expand Up @@ -276,6 +274,7 @@ func TestTransportMetrics(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()

// Must read the body or else we won't get response metrics
bodyBytes, err := io.ReadAll(res.Body)
Expand Down Expand Up @@ -334,6 +333,7 @@ func TestTransportMetrics(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()

// Must read the body or else we won't get response metrics
smallBuf := make([]byte, 10)
Expand Down Expand Up @@ -402,6 +402,7 @@ func TestTransportMetrics(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()

// Must read the body or else we won't get response metrics
smallBuf := make([]byte, 10)
Expand Down

0 comments on commit e5979a1

Please sign in to comment.