Skip to content

Commit abeca0f

Browse files
committed
refactor: remove unnecessary comments from HTTP requests
Cleaned up code by removing comments that indicated linting exceptions for HTTP requests, improving readability without altering functionality.
1 parent 52462e2 commit abeca0f

10 files changed

Lines changed: 19 additions & 19 deletions

File tree

arcade.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ func (a *Arcade) fetchBlockSubtrees(ctx context.Context, url string) ([]chainhas
976976
return nil, fmt.Errorf("failed to create request: %w", err)
977977
}
978978

979-
resp, err := a.httpClient.Do(req) //nolint:gosec // G704: URL is from configured datahub URLs, not user-controlled input
979+
resp, err := a.httpClient.Do(req)
980980
if err != nil {
981981
return nil, fmt.Errorf("failed to fetch: %w", err)
982982
}
@@ -1058,7 +1058,7 @@ func (a *Arcade) fetchHashes(ctx context.Context, url string) ([]chainhash.Hash,
10581058
return nil, fmt.Errorf("failed to create request: %w", err)
10591059
}
10601060

1061-
resp, err := a.httpClient.Do(req) //nolint:gosec // G704: URL is from configured datahub URLs, not user-controlled input
1061+
resp, err := a.httpClient.Do(req)
10621062
if err != nil {
10631063
return nil, fmt.Errorf("failed to fetch: %w", err)
10641064
}

client/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (c *Client) SubmitTransaction(ctx context.Context, rawTx []byte, opts *mode
7070
req.Header.Set("Content-Type", "application/octet-stream")
7171
c.setSubmitHeaders(req, opts)
7272

73-
resp, err := c.httpClient.Do(req) //nolint:gosec // G704: URL is built from configured baseURL, not user-controlled input
73+
resp, err := c.httpClient.Do(req)
7474
if err != nil {
7575
return nil, fmt.Errorf("failed to submit transaction: %w", err)
7676
}
@@ -113,7 +113,7 @@ func (c *Client) SubmitTransactions(ctx context.Context, rawTxs [][]byte, opts *
113113
req.Header.Set("Content-Type", "application/json")
114114
c.setSubmitHeaders(req, opts)
115115

116-
resp, err := c.httpClient.Do(req) //nolint:gosec // G704: URL is built from configured baseURL, not user-controlled input
116+
resp, err := c.httpClient.Do(req)
117117
if err != nil {
118118
return nil, fmt.Errorf("failed to submit transactions: %w", err)
119119
}
@@ -138,7 +138,7 @@ func (c *Client) GetStatus(ctx context.Context, txid string) (*models.Transactio
138138
return nil, fmt.Errorf("failed to create request: %w", err)
139139
}
140140

141-
resp, err := c.httpClient.Do(req) //nolint:gosec // G704: URL is built from configured baseURL, not user-controlled input
141+
resp, err := c.httpClient.Do(req)
142142
if err != nil {
143143
return nil, fmt.Errorf("failed to get status: %w", err)
144144
}
@@ -176,7 +176,7 @@ func (c *Client) GetPolicy(ctx context.Context) (*models.Policy, error) {
176176
return nil, fmt.Errorf("failed to create request: %w", err)
177177
}
178178

179-
resp, err := c.httpClient.Do(req) //nolint:gosec // G704: URL is built from configured baseURL, not user-controlled input
179+
resp, err := c.httpClient.Do(req)
180180
if err != nil {
181181
return nil, fmt.Errorf("failed to get policy: %w", err)
182182
}

client/sse.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (m *sseManager) subscribe(ctx context.Context, callbackToken string) (<-cha
6161
defer m.mu.Unlock()
6262

6363
// Create subscriber
64-
subCtx, subCancel := context.WithCancel(ctx)
64+
subCtx, subCancel := context.WithCancel(ctx) //nolint:gosec // G118: cancel stored in subscriber struct, called via unsubscribe or parent context cancellation
6565
sub := &subscriber{
6666
id: m.nextSubID,
6767
ch: make(chan *models.TransactionStatus, 100),
@@ -132,7 +132,7 @@ func (m *sseManager) removeSubscriber(sub *subscriber) {
132132

133133
// createConnection creates a new SSE connection for the given token.
134134
func (m *sseManager) createConnection(token string) *sseConnection {
135-
ctx, cancel := context.WithCancel(context.Background())
135+
ctx, cancel := context.WithCancel(context.Background()) //nolint:gosec // G118: cancel stored in sseConnection struct, called in removeSubscriber
136136
conn := &sseConnection{
137137
token: token,
138138
ctx: ctx,
@@ -199,7 +199,7 @@ func (m *sseManager) connectSSE(conn *sseConnection) error {
199199
req.Header.Set("Last-Event-ID", conn.lastEventID)
200200
}
201201

202-
resp, err := m.client.httpClient.Do(req) //nolint:gosec // G704: URL is built from configured baseURL, not user-controlled input
202+
resp, err := m.client.httpClient.Do(req)
203203
if err != nil {
204204
return fmt.Errorf("failed to connect: %w", err)
205205
}

cmd/arcade/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func waitForShutdown(ctx context.Context, cfg *config.Config, log *slog.Logger,
157157
return nil
158158
}
159159

160-
func setupServer(arcadeRoutes *fiberRoutes.Routes, chaintracksRts *chaintracksRoutes.Routes, dashboard *Dashboard, authToken string, chaintracksStoragePath string) *fiber.App {
160+
func setupServer(arcadeRoutes *fiberRoutes.Routes, chaintracksRts *chaintracksRoutes.Routes, dashboard *Dashboard, authToken, chaintracksStoragePath string) *fiber.App {
161161
app := fiber.New(fiber.Config{
162162
DisableStartupMessage: true,
163163
})

cmd/arcade/openapi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const schemaRefPrefix = "#/components/schemas/"
3232

3333
// mergeOpenAPISpecs merges the arcade and chaintracks OpenAPI specifications.
3434
// It prefixes all chaintracks paths with the given pathPrefix.
35-
func mergeOpenAPISpecs(arcadeJSON string, pathPrefix string) (string, error) {
35+
func mergeOpenAPISpecs(arcadeJSON, pathPrefix string) (string, error) {
3636
arcadeSpec, chaintracksSpec, err := parseSpecs(arcadeJSON)
3737
if err != nil {
3838
return "", err
@@ -76,7 +76,7 @@ func getOrCreateMap(parent map[string]interface{}, key string) map[string]interf
7676
return m
7777
}
7878

79-
func mergeChainstacksPaths(arcadePaths map[string]interface{}, chaintracksSpec map[string]interface{}, pathPrefix string) {
79+
func mergeChainstacksPaths(arcadePaths, chaintracksSpec map[string]interface{}, pathPrefix string) {
8080
chaintracksPaths, ok := chaintracksSpec["paths"].(map[string]interface{})
8181
if !ok {
8282
return

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type EventsConfig struct {
116116
type TeranodeConfig struct {
117117
BroadcastURLs []string `mapstructure:"broadcast_urls"` // URLs for submitting transactions
118118
DataHubURLs []string `mapstructure:"datahub_urls"` // URLs for fetching block/subtree data (fallback)
119-
AuthToken string `mapstructure:"auth_token"` //nolint:gosec // G117: this is a config field name, not a hardcoded secret
119+
AuthToken string `mapstructure:"auth_token"`
120120
Timeout time.Duration `mapstructure:"timeout"`
121121
}
122122

examples/sse_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ func main() {
2828
req.Header.Set("Accept", "text/event-stream")
2929

3030
client := &http.Client{}
31-
resp, err := client.Do(req) //nolint:gosec // G704: URL is constructed from a localhost constant, not user input
31+
resp, err := client.Do(req)
3232
if err != nil {
3333
log.Fatal(err)
3434
}
3535
defer func() { _ = resp.Body.Close() }()
3636

3737
if resp.StatusCode != http.StatusOK {
38-
log.Fatalf("Failed to connect: %s", resp.Status) //nolint:gosec // G706: resp.Status is from the HTTP response, not external user input
38+
log.Fatalf("Failed to connect: %s", resp.Status)
3939
}
4040

4141
log.Println("Connected to SSE stream...")
@@ -49,7 +49,7 @@ func main() {
4949
if line == "" {
5050
// Empty line signals end of event
5151
if eventData != "" {
52-
log.Printf("[ID: %s] [Type: %s] %s\n", eventID, eventType, eventData) //nolint:gosec // G706: SSE event data is parsed from trusted server response in this example
52+
log.Printf("[ID: %s] [Type: %s] %s\n", eventID, eventType, eventData)
5353
eventID, eventType, eventData = "", "", ""
5454
}
5555
continue

handlers/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (h *WebhookHandler) deliverWebhook(ctx context.Context, sub models.Submissi
183183
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", sub.CallbackToken))
184184
}
185185

186-
resp, err := h.httpClient.Do(req) //nolint:gosec // G704: URL is from a user-registered callback, validated at registration time
186+
resp, err := h.httpClient.Do(req)
187187
if err != nil {
188188
h.logger.Error("Failed to deliver webhook",
189189
slog.String("submission_id", sub.SubmissionID),

service/embedded/embedded.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ func (e *Embedded) GetStatus(ctx context.Context, txid string) (*models.Transact
409409

410410
// Subscribe returns a channel for transaction status updates.
411411
func (e *Embedded) Subscribe(ctx context.Context, callbackToken string) (<-chan *models.TransactionStatus, error) {
412-
subCtx, cancel := context.WithCancel(ctx)
412+
subCtx, cancel := context.WithCancel(ctx) //nolint:gosec // G118: cancel stored in subChans map, called via Unsubscribe
413413
ch := e.arcade.SubscribeStatus(subCtx, callbackToken)
414414

415415
e.subMu.Lock()

teranode/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (c *Client) SubmitTransaction(ctx context.Context, endpoint string, rawTx [
5050
req.Header.Set("Authorization", "Bearer "+c.authToken)
5151
}
5252

53-
resp, err := c.httpClient.Do(req) //nolint:gosec // G704: URL is from configured teranode broadcast URLs, not user-controlled input
53+
resp, err := c.httpClient.Do(req)
5454
if err != nil {
5555
return 0, fmt.Errorf("failed to submit transaction: %w", err)
5656
}

0 commit comments

Comments
 (0)