Skip to content

Commit 8c76a78

Browse files
authored
refactor: lint code (#39)
* fix non-constant format string error * lint
1 parent 2e87685 commit 8c76a78

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

api/api.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (cl Client) newRequest(ctx context.Context, method, url string) (*http.Requ
8181
return req, err
8282
}
8383

84-
func (cl Client) Request(ctx context.Context, method, url string, out interface{}) error {
84+
func (cl Client) Request(ctx context.Context, method, url string, out interface{}) (err error) {
8585
req, err := cl.newRequest(ctx, method, url)
8686
if err != nil {
8787
return fmt.Errorf("new request: %w", err)
@@ -90,7 +90,13 @@ func (cl Client) Request(ctx context.Context, method, url string, out interface{
9090
if err != nil {
9191
return fmt.Errorf("do request: %w", err)
9292
}
93-
defer resp.Body.Close()
93+
defer func() {
94+
if closeErr := resp.Body.Close(); closeErr != nil {
95+
if err == nil {
96+
err = fmt.Errorf("close response body: %w", closeErr)
97+
}
98+
}
99+
}()
94100
if resp.StatusCode != http.StatusOK {
95101
return fmt.Errorf("%w: %d", ErrBadStatusCode, resp.StatusCode)
96102
}

detector/detector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func unmarshalFromFile(fn string, out any) error {
156156
if err != nil {
157157
return err
158158
}
159-
defer f.Close()
159+
defer func() { _ = f.Close() }()
160160
return json.NewDecoder(f).Decode(out)
161161
}
162162

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ func handleReadyRequest(w http.ResponseWriter, r *http.Request, ready *atomic.Bo
223223

224224
if ready.Load() {
225225
w.WriteHeader(http.StatusOK)
226-
w.Write([]byte("Ready"))
226+
_, _ = w.Write([]byte("Ready"))
227227
} else {
228228
w.WriteHeader(http.StatusServiceUnavailable)
229-
w.Write([]byte("Not Ready"))
229+
_, _ = w.Write([]byte("Not Ready"))
230230
}
231231
}
232232

output/output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (o LoggerReadableOutput) Output(v []Dashboard) error {
7575
}
7676
o.log.Log("Found dashboard with Angular plugins %q %q:", dashboard.Title, dashboard.URL)
7777
for _, detection := range dashboard.Detections {
78-
o.log.Log(detection.String())
78+
o.log.Log("%s", detection.String())
7979
}
8080
}
8181
return nil

0 commit comments

Comments
 (0)