Skip to content

Commit 5910ff0

Browse files
committed
github action lint
1 parent e773b41 commit 5910ff0

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

github/commitstatus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (cs CommitStatus) Add(ctx context.Context, sha, state, targetURL, descripti
135135
if err != nil {
136136
return fmt.Errorf("http client Do: %w", err)
137137
}
138-
defer resp.Body.Close()
138+
defer resp.Body.Close() //nolint:errcheck
139139

140140
elapsed := time.Since(start)
141141
remaining := resp.Header.Get("X-RateLimit-Remaining")

github/commitstatus_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestGitHubStatusSuccessMockAPI(t *testing.T) {
6161
now := time.Now()
6262
desc := now.Format("15:04:05")
6363

64-
run := func(t *testing.T, tc testCase) {
64+
test := func(t *testing.T, tc testCase) {
6565
attempt := 0
6666
handler := func(w http.ResponseWriter, r *http.Request) {
6767
response := tc.response[attempt]
@@ -71,7 +71,10 @@ func TestGitHubStatusSuccessMockAPI(t *testing.T) {
7171
w.Header().Set("x-ratelimit-remaining", response.rateLimitRemaining)
7272
w.Header().Set("x-ratelimit-reset", strconv.Itoa(int(response.rateLimitReset)))
7373
w.WriteHeader(response.status)
74-
fmt.Fprintln(w, response.body)
74+
_, err := fmt.Fprintln(w, response.body)
75+
if err != nil {
76+
t.Fatalf("writing response body: %s", err)
77+
}
7578
attempt++
7679
}
7780
ts := httptest.NewServer(http.HandlerFunc(handler))
@@ -180,7 +183,7 @@ func TestGitHubStatusSuccessMockAPI(t *testing.T) {
180183
}
181184

182185
for _, tc := range testCases {
183-
t.Run(tc.name, func(t *testing.T) { run(t, tc) })
186+
t.Run(tc.name, func(t *testing.T) { test(t, tc) })
184187
}
185188
}
186189

@@ -218,7 +221,10 @@ func TestGitHubStatusFailureMockAPI(t *testing.T) {
218221
// for better control.
219222
w.Header().Set("Date", now.Format(time.RFC1123))
220223
w.WriteHeader(response.status)
221-
fmt.Fprintln(w, response.body)
224+
_, err := fmt.Fprintln(w, response.body)
225+
if err != nil {
226+
t.Fatalf("writing response body: %s", err)
227+
}
222228
attempt++
223229
}
224230
ts := httptest.NewServer(http.HandlerFunc(handler))

github/githubapp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func GenerateInstallationToken(ctx context.Context, client *http.Client, server
7676
if err != nil {
7777
return "", fmt.Errorf("http client Do: %s", err)
7878
}
79-
defer resp.Body.Close()
79+
defer resp.Body.Close() //nolint:errcheck
8080

8181
body, errBody := io.ReadAll(resp.Body)
8282
if resp.StatusCode != http.StatusCreated {

github/githubapp_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,27 @@ func TestGenerateInstallationToken(t *testing.T) {
2323
handler := func(w http.ResponseWriter, r *http.Request) {
2424
if r.Method != http.MethodPost {
2525
w.WriteHeader(http.StatusMethodNotAllowed)
26-
fmt.Fprintln(w, "wrong HTTP method")
26+
_, err := fmt.Fprintln(w, "wrong HTTP method")
27+
if err != nil {
28+
t.Fatalf("writing response: %s", err)
29+
}
2730
return
2831
}
2932

3033
claims := decodeJWT(t, r, privateKey)
3134
if claims.Issuer != clientID {
3235
w.WriteHeader(http.StatusUnauthorized)
33-
fmt.Fprintln(w, "unauthorized: wrong JWT token")
36+
_, err := fmt.Fprintln(w, "unauthorized: wrong JWT token")
37+
if err != nil {
38+
t.Fatalf("writing response: %s", err)
39+
}
3440
return
3541
}
3642
w.WriteHeader(http.StatusCreated)
37-
fmt.Fprintln(w, `{"token": "dummy_installation_token"}`)
43+
_, err := fmt.Fprintln(w, `{"token": "dummy_installation_token"}`)
44+
if err != nil {
45+
t.Fatalf("writing response: %s", err)
46+
}
3847
}
3948

4049
ts := httptest.NewServer(http.HandlerFunc(handler))

0 commit comments

Comments
 (0)