Skip to content

Commit 14b70d5

Browse files
Fix linters issues (google#2104)
1 parent e880e71 commit 14b70d5

13 files changed

+16
-24
lines changed

.golangci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ linters:
1111
# - gosec
1212
- misspell
1313
- nakedret
14-
# - stylecheck
14+
- stylecheck
1515
# - unconvert
1616
# - unparam
17-
# - whitespace
17+
- whitespace
1818
disable:
1919
- errcheck
2020
- gosimple

example/commitpr/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ func getRef() (ref *github.Reference, err error) {
6767
// We consider that an error means the branch has not been found and needs to
6868
// be created.
6969
if *commitBranch == *baseBranch {
70-
return nil, errors.New("The commit branch does not exist but `-base-branch` is the same as `-commit-branch`")
70+
return nil, errors.New("the commit branch does not exist but `-base-branch` is the same as `-commit-branch`")
7171
}
7272

7373
if *baseBranch == "" {
74-
return nil, errors.New("The `-base-branch` should not be set to an empty string when the branch specified by `-commit-branch` does not exists")
74+
return nil, errors.New("the `-base-branch` should not be set to an empty string when the branch specified by `-commit-branch` does not exists")
7575
}
7676

7777
var baseRef *github.Reference

github/actions_workflow_jobs.go

-1
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,4 @@ func (s *ActionsService) getWorkflowLogsFromURL(ctx context.Context, u string, f
147147
resp, err = s.getWorkflowLogsFromURL(ctx, u, false)
148148
}
149149
return resp, err
150-
151150
}

github/actions_workflow_runs_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ func TestActionService_ListRepositoryWorkflowRuns(t *testing.T) {
295295
"workflow_runs":[
296296
{"id":298499444,"run_number":301,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"},
297297
{"id":298499445,"run_number":302,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}]}`)
298-
299298
})
300299

301300
opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}}

github/enterprise_audit_log_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,4 @@ func TestEnterpriseService_GetAuditLog(t *testing.T) {
9696
}
9797
return resp, err
9898
})
99-
10099
}

github/github.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,10 @@ func (c *Client) checkRateLimitBeforeDo(req *http.Request, rateLimitCategory rat
708708
return nil
709709
}
710710

711-
// compareHttpResponse returns whether two http.Response objects are equal or not.
711+
// compareHTTPResponse returns whether two http.Response objects are equal or not.
712712
// Currently, only StatusCode is checked. This function is used when implementing the
713713
// Is(error) bool interface for the custom error types in this package.
714-
func compareHttpResponse(r1, r2 *http.Response) bool {
714+
func compareHTTPResponse(r1, r2 *http.Response) bool {
715715
if r1 == nil && r2 == nil {
716716
return true
717717
}
@@ -761,7 +761,7 @@ func (r *ErrorResponse) Is(target error) bool {
761761
}
762762

763763
if r.Message != v.Message || (r.DocumentationURL != v.DocumentationURL) ||
764-
!compareHttpResponse(r.Response, v.Response) {
764+
!compareHTTPResponse(r.Response, v.Response) {
765765
return false
766766
}
767767

@@ -827,7 +827,7 @@ func (r *RateLimitError) Is(target error) bool {
827827

828828
return r.Rate == v.Rate &&
829829
r.Message == v.Message &&
830-
compareHttpResponse(r.Response, v.Response)
830+
compareHTTPResponse(r.Response, v.Response)
831831
}
832832

833833
// AcceptedError occurs when GitHub returns 202 Accepted response with an
@@ -881,7 +881,7 @@ func (r *AbuseRateLimitError) Is(target error) bool {
881881

882882
return r.Message == v.Message &&
883883
r.RetryAfter == v.RetryAfter &&
884-
compareHttpResponse(r.Response, v.Response)
884+
compareHTTPResponse(r.Response, v.Response)
885885
}
886886

887887
// sanitizeURL redacts the client_secret parameter from the URL which may be

github/github_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ func TestCompareHttpResponse(t *testing.T) {
12291229

12301230
for name, tc := range testcases {
12311231
t.Run(name, func(t *testing.T) {
1232-
v := compareHttpResponse(tc.h1, tc.h2)
1232+
v := compareHTTPResponse(tc.h1, tc.h2)
12331233
if tc.expected != v {
12341234
t.Errorf("Expected %t, got %t for (%#v, %#v)", tc.expected, v, tc.h1, tc.h2)
12351235
}
@@ -2028,7 +2028,6 @@ func TestAddOptions_QueryValues(t *testing.T) {
20282028
}
20292029

20302030
func TestBareDo_returnsOpenBody(t *testing.T) {
2031-
20322031
client, mux, _, teardown := setup()
20332032
defer teardown()
20342033

github/messages.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func ValidatePayloadFromBody(contentType string, readable io.Reader, signature s
192192
payload = []byte(form.Get(payloadFormParam))
193193

194194
default:
195-
return nil, fmt.Errorf("Webhook request has unsupported Content-Type %q", contentType)
195+
return nil, fmt.Errorf("webhook request has unsupported Content-Type %q", contentType)
196196
}
197197

198198
// Only validate the signature if a secret token exists. This is intended for

github/orgs_audit_log_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ func TestOrganizationService_GetAuditLog(t *testing.T) {
110110
}
111111
return resp, err
112112
})
113-
114113
}
115114

116115
func TestGetAuditLogOptions_Marshal(t *testing.T) {

github/orgs_members_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ func TestOrganizationsService_CreateOrgInvitation(t *testing.T) {
655655
}
656656

657657
fmt.Fprintln(w, `{"email": "[email protected]"}`)
658-
659658
})
660659

661660
ctx := context.Background()

github/orgs_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ func TestOrganizationsService_ListInstallations_invalidOrg(t *testing.T) {
357357
ctx := context.Background()
358358
_, _, err := client.Organizations.ListInstallations(ctx, "%", nil)
359359
testURLParseError(t, err)
360-
361360
}
362361

363362
func TestOrganizationsService_ListInstallations_withListOptions(t *testing.T) {

github/repos_contents.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo,
132132
for _, contents := range dirContents {
133133
if *contents.Name == filename {
134134
if contents.DownloadURL == nil || *contents.DownloadURL == "" {
135-
return nil, resp, fmt.Errorf("No download link found for %s", filepath)
135+
return nil, resp, fmt.Errorf("no download link found for %s", filepath)
136136
}
137137
dlResp, err := s.client.client.Get(*contents.DownloadURL)
138138
if err != nil {
@@ -141,7 +141,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo,
141141
return dlResp.Body, &Response{Response: dlResp}, nil
142142
}
143143
}
144-
return nil, resp, fmt.Errorf("No file named %s found in %s", filename, dir)
144+
return nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir)
145145
}
146146

147147
// DownloadContentsWithMeta is identical to DownloadContents but additionally
@@ -162,7 +162,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne
162162
for _, contents := range dirContents {
163163
if *contents.Name == filename {
164164
if contents.DownloadURL == nil || *contents.DownloadURL == "" {
165-
return nil, contents, resp, fmt.Errorf("No download link found for %s", filepath)
165+
return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath)
166166
}
167167
dlResp, err := s.client.client.Get(*contents.DownloadURL)
168168
if err != nil {
@@ -171,7 +171,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne
171171
return dlResp.Body, contents, &Response{Response: dlResp}, nil
172172
}
173173
}
174-
return nil, nil, resp, fmt.Errorf("No file named %s found in %s", filename, dir)
174+
return nil, nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir)
175175
}
176176

177177
// GetContents can return either the metadata and content of a single file

github/repos_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,6 @@ func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *test
10901090
defer teardown()
10911091

10921092
mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
1093-
10941093
testMethod(t, r, "GET")
10951094
// TODO: remove custom Accept header when this API fully launches
10961095
testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
@@ -2319,8 +2318,8 @@ func TestRepositoriesService_Dispatch(t *testing.T) {
23192318
Baz: false,
23202319
},
23212320
}
2322-
for _, tc := range testCases {
23232321

2322+
for _, tc := range testCases {
23242323
if tc == nil {
23252324
input = DispatchRequestOptions{EventType: "go"}
23262325
} else {

0 commit comments

Comments
 (0)