Skip to content

Commit 53ba0c6

Browse files
committed
tidy up linter errors
1 parent bd12ce6 commit 53ba0c6

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

backend/internal/services/adapters/raw.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ func (ra *RawAdapter) UnmarshalRequest(r *http.Request) error {
5252
var bodyData any
5353
if isEmpty(ra.CreateDTO.RawRequest) {
5454
if json.Valid(bodyBytes) {
55-
json.Unmarshal(bodyBytes, &bodyData)
55+
_ = json.Unmarshal(bodyBytes, &bodyData)
5656
} else {
5757
bodyData = map[string]string{"body": string(bodyBytes)}
5858
}
5959
} else {
6060
// Use existing RawRequest
61-
json.Unmarshal(ra.CreateDTO.RawRequest, &bodyData)
61+
_ = json.Unmarshal(ra.CreateDTO.RawRequest, &bodyData)
6262
}
6363

6464
// Convert headers to http.Header format
@@ -69,7 +69,7 @@ func (ra *RawAdapter) UnmarshalRequest(r *http.Request) error {
6969
}
7070
} else {
7171
// Keep existing headers
72-
json.Unmarshal(ra.CreateDTO.RawHeaders, &headers)
72+
_ = json.Unmarshal(ra.CreateDTO.RawHeaders, &headers)
7373
}
7474

7575
// Get query params
@@ -78,7 +78,7 @@ func (ra *RawAdapter) UnmarshalRequest(r *http.Request) error {
7878
queryParams = r.URL.Query()
7979
} else {
8080
// Keep existing query params
81-
json.Unmarshal(ra.CreateDTO.RawQueryParams, &queryParams)
81+
_ = json.Unmarshal(ra.CreateDTO.RawQueryParams, &queryParams)
8282
}
8383

8484
// Use constructor to ensure proper initialization

backend/internal/services/adapters/utils.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/hay-kot/hookfeed/backend/internal/data/dtos"
1414
)
1515

16+
const redactedValue = "<redacted>"
17+
1618
// GetHeader retrieves a header value, trying multiple possible keys
1719
func GetHeader(r *http.Request, keys ...string) string {
1820
for _, key := range keys {
@@ -90,21 +92,21 @@ func sanitizeSecrets(key, value string) string {
9092
// Handle Bearer, Basic, and other auth schemes
9193
parts := strings.SplitN(value, " ", 2)
9294
if len(parts) == 2 {
93-
return parts[0] + " <redacted>"
95+
return parts[0] + " " + redactedValue
9496
}
95-
return "<redacted>"
97+
return redactedValue
9698

9799
case "cookie", "set-cookie":
98-
return "<redacted>"
100+
return redactedValue
99101

100102
case "x-api-key", "x-auth-token", "api-key", "apikey":
101-
return "<redacted>"
103+
return redactedValue
102104
}
103105

104106
// Redact query parameters that commonly contain secrets
105107
if keyLower == "token" || keyLower == "api_key" || keyLower == "apikey" ||
106108
keyLower == "secret" || keyLower == "password" || keyLower == "key" {
107-
return "<redacted>"
109+
return redactedValue
108110
}
109111

110112
return value
@@ -181,7 +183,7 @@ func copyBody(r *http.Request) ([]byte, error) {
181183
if err != nil {
182184
return nil, fmt.Errorf("failed to read request body: %w", err)
183185
}
184-
defer r.Body.Close()
186+
_ = r.Body.Close()
185187

186188
r.Body = io.NopCloser(bytes.NewReader(body))
187189

@@ -205,19 +207,3 @@ func copyBody(r *http.Request) ([]byte, error) {
205207

206208
return json.Marshal(wrapped)
207209
}
208-
209-
// isEmptyJSON checks if the given JSON byte slice represents an empty value
210-
// Returns true for: '{}', ”, 'null', '[]', or whitespace-only strings
211-
func isEmptyJSON(data []byte) bool {
212-
// Trim whitespace
213-
trimmed := bytes.TrimSpace(data)
214-
215-
// Check for empty string
216-
if len(trimmed) == 0 {
217-
return true
218-
}
219-
220-
// Check for common empty JSON representations
221-
s := string(trimmed)
222-
return s == "{}" || s == "null" || s == "[]"
223-
}

0 commit comments

Comments
 (0)