Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fix linters issues #2104

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ linters:
# - gosec
- misspell
- nakedret
# - stylecheck
- stylecheck
# - unconvert
# - unparam
# - whitespace
- whitespace
disable:
- errcheck
- gosimple
Expand Down
4 changes: 2 additions & 2 deletions example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ func getRef() (ref *github.Reference, err error) {
// We consider that an error means the branch has not been found and needs to
// be created.
if *commitBranch == *baseBranch {
return nil, errors.New("The commit branch does not exist but `-base-branch` is the same as `-commit-branch`")
return nil, errors.New("the commit branch does not exist but `-base-branch` is the same as `-commit-branch`")
}

if *baseBranch == "" {
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")
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")
}

var baseRef *github.Reference
Expand Down
1 change: 0 additions & 1 deletion github/actions_workflow_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,4 @@ func (s *ActionsService) getWorkflowLogsFromURL(ctx context.Context, u string, f
resp, err = s.getWorkflowLogsFromURL(ctx, u, false)
}
return resp, err

}
1 change: 0 additions & 1 deletion github/actions_workflow_runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ func TestActionService_ListRepositoryWorkflowRuns(t *testing.T) {
"workflow_runs":[
{"id":298499444,"run_number":301,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"},
{"id":298499445,"run_number":302,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}]}`)

})

opts := &ListWorkflowRunsOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}}
Expand Down
1 change: 0 additions & 1 deletion github/enterprise_audit_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,4 @@ func TestEnterpriseService_GetAuditLog(t *testing.T) {
}
return resp, err
})

}
10 changes: 5 additions & 5 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,10 @@ func (c *Client) checkRateLimitBeforeDo(req *http.Request, rateLimitCategory rat
return nil
}

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

if r.Message != v.Message || (r.DocumentationURL != v.DocumentationURL) ||
!compareHttpResponse(r.Response, v.Response) {
!compareHTTPResponse(r.Response, v.Response) {
return false
}

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

return r.Rate == v.Rate &&
r.Message == v.Message &&
compareHttpResponse(r.Response, v.Response)
compareHTTPResponse(r.Response, v.Response)
}

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

return r.Message == v.Message &&
r.RetryAfter == v.RetryAfter &&
compareHttpResponse(r.Response, v.Response)
compareHTTPResponse(r.Response, v.Response)
}

// sanitizeURL redacts the client_secret parameter from the URL which may be
Expand Down
3 changes: 1 addition & 2 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ func TestCompareHttpResponse(t *testing.T) {

for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
v := compareHttpResponse(tc.h1, tc.h2)
v := compareHTTPResponse(tc.h1, tc.h2)
if tc.expected != v {
t.Errorf("Expected %t, got %t for (%#v, %#v)", tc.expected, v, tc.h1, tc.h2)
}
Expand Down Expand Up @@ -2028,7 +2028,6 @@ func TestAddOptions_QueryValues(t *testing.T) {
}

func TestBareDo_returnsOpenBody(t *testing.T) {

client, mux, _, teardown := setup()
defer teardown()

Expand Down
2 changes: 1 addition & 1 deletion github/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func ValidatePayloadFromBody(contentType string, readable io.Reader, signature s
payload = []byte(form.Get(payloadFormParam))

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

// Only validate the signature if a secret token exists. This is intended for
Expand Down
1 change: 0 additions & 1 deletion github/orgs_audit_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func TestOrganizationService_GetAuditLog(t *testing.T) {
}
return resp, err
})

}

func TestGetAuditLogOptions_Marshal(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion github/orgs_members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ func TestOrganizationsService_CreateOrgInvitation(t *testing.T) {
}

fmt.Fprintln(w, `{"email": "[email protected]"}`)

})

ctx := context.Background()
Expand Down
1 change: 0 additions & 1 deletion github/orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ func TestOrganizationsService_ListInstallations_invalidOrg(t *testing.T) {
ctx := context.Background()
_, _, err := client.Organizations.ListInstallations(ctx, "%", nil)
testURLParseError(t, err)

}

func TestOrganizationsService_ListInstallations_withListOptions(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions github/repos_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo,
for _, contents := range dirContents {
if *contents.Name == filename {
if contents.DownloadURL == nil || *contents.DownloadURL == "" {
return nil, resp, fmt.Errorf("No download link found for %s", filepath)
return nil, resp, fmt.Errorf("no download link found for %s", filepath)
}
dlResp, err := s.client.client.Get(*contents.DownloadURL)
if err != nil {
Expand All @@ -141,7 +141,7 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo,
return dlResp.Body, &Response{Response: dlResp}, nil
}
}
return nil, resp, fmt.Errorf("No file named %s found in %s", filename, dir)
return nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir)
}

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

// GetContents can return either the metadata and content of a single file
Expand Down
3 changes: 1 addition & 2 deletions github/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,6 @@ func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *test
defer teardown()

mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {

testMethod(t, r, "GET")
// TODO: remove custom Accept header when this API fully launches
testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
Expand Down Expand Up @@ -2319,8 +2318,8 @@ func TestRepositoriesService_Dispatch(t *testing.T) {
Baz: false,
},
}
for _, tc := range testCases {

for _, tc := range testCases {
if tc == nil {
input = DispatchRequestOptions{EventType: "go"}
} else {
Expand Down