Skip to content

Commit 186d762

Browse files
authored
Merge pull request #1 from theurzil/fix/resolve-golangci-lint-issues
fix: resolve golangci-lint issues
2 parents b499f5f + 10f146a commit 186d762

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

client.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package rubygemsclient
44

55
import (
6+
"context"
67
"encoding/json"
78
"fmt"
89
"net/http"
@@ -63,7 +64,12 @@ func (c *Client) GetGemInfo(name, version string) (*GemInfo, error) {
6364
// In production, we'd use the compact index or version-specific APIs
6465
url := fmt.Sprintf("%s/gems/%s.json", c.baseURL, name)
6566

66-
resp, err := c.httpClient.Get(url)
67+
req, err := http.NewRequestWithContext(context.Background(), "GET", url, http.NoBody)
68+
if err != nil {
69+
return nil, fmt.Errorf("failed to create request: %w", err)
70+
}
71+
72+
resp, err := c.httpClient.Do(req)
6773
if err != nil {
6874
return nil, fmt.Errorf("failed to fetch gem info: %w", err)
6975
}
@@ -94,7 +100,12 @@ type VersionInfo struct {
94100
func (c *Client) GetGemVersions(name string) ([]string, error) {
95101
url := fmt.Sprintf("%s/versions/%s.json", c.baseURL, name)
96102

97-
resp, err := c.httpClient.Get(url)
103+
req, err := http.NewRequestWithContext(context.Background(), "GET", url, http.NoBody)
104+
if err != nil {
105+
return nil, fmt.Errorf("failed to create request: %w", err)
106+
}
107+
108+
resp, err := c.httpClient.Do(req)
98109
if err != nil {
99110
return nil, fmt.Errorf("failed to fetch gem versions: %w", err)
100111
}
@@ -165,4 +176,3 @@ func (c *Client) GetMultipleGemInfo(requests []GemInfoRequest) []GemInfoResult {
165176
wg.Wait()
166177
return results
167178
}
168-

client_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"net/http/httptest"
77
"testing"
88
"time"
9-
109
)
1110

1211
func TestNewClient(t *testing.T) {
@@ -50,7 +49,7 @@ func TestGetGemInfo_Success(t *testing.T) {
5049
}
5150

5251
w.Header().Set("Content-Type", "application/json")
53-
json.NewEncoder(w).Encode(response)
52+
_ = json.NewEncoder(w).Encode(response)
5453
}))
5554
defer server.Close()
5655

@@ -117,7 +116,7 @@ func TestGetGemVersions_Success(t *testing.T) {
117116
}
118117

119118
w.Header().Set("Content-Type", "application/json")
120-
json.NewEncoder(w).Encode(versions)
119+
_ = json.NewEncoder(w).Encode(versions)
121120
}))
122121
defer server.Close()
123122

@@ -152,7 +151,7 @@ func TestGetGemVersions_TooManyVersions(t *testing.T) {
152151
}
153152

154153
w.Header().Set("Content-Type", "application/json")
155-
json.NewEncoder(w).Encode(versions)
154+
_ = json.NewEncoder(w).Encode(versions)
156155
}))
157156
defer server.Close()
158157

@@ -186,7 +185,7 @@ func TestGetMultipleGemInfo(t *testing.T) {
186185
}
187186

188187
w.Header().Set("Content-Type", "application/json")
189-
json.NewEncoder(w).Encode(response)
188+
_ = json.NewEncoder(w).Encode(response)
190189
}))
191190
defer server.Close()
192191

@@ -233,4 +232,3 @@ func contains(s, substr string) bool {
233232
return len(s) >= len(substr) && s[:len(substr)] == substr ||
234233
(len(s) > len(substr) && contains(s[1:], substr))
235234
}
236-

0 commit comments

Comments
 (0)