Repository: google/go-github
Pull request #2104 (2021-09-26 20:32:32)

Some fix linters issues

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2104](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (62fd464) into [master](https://codecov.io/gh/google/go-github/commit/e880e71a970a23fa7fe103599872fabda33ddde2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (e880e71) will **not change** coverage.
> The diff coverage is `77.77%`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/2104/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #2104   +/-   ##
=======================================
  Coverage   97.77%   97.77%           
=======================================
  Files         109      109           
  Lines        9726     9726           
=======================================
  Hits         9510     9510           
  Misses        150      150           
  Partials       66       66           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/actions\_workflow\_jobs.go](https://codecov.io/gh/google/go-github/pull/2104/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2FjdGlvbnNfd29ya2Zsb3dfam9icy5nbw==) | `100.00% <ø> (ø)` | |
| [github/repos\_contents.go](https://codecov.io/gh/google/go-github/pull/2104/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL3JlcG9zX2NvbnRlbnRzLmdv) | `88.95% <50.00%> (ø)` | |
| [github/github.go](https://codecov.io/gh/google/go-github/pull/2104/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2dpdGh1Yi5nbw==) | `97.58% <100.00%> (ø)` | |
| [github/messages.go](https://codecov.io/gh/google/go-github/pull/2104/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL21lc3NhZ2VzLmdv) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [e880e71...62fd464](https://codecov.io/gh/google/go-github/pull/2104?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/.golangci.yml b/.golangci.yml
index afd9675f..db9a4d71 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -11,10 +11,10 @@ linters:
   # - gosec
     - misspell
     - nakedret
-  # - stylecheck
+    - stylecheck
   # - unconvert
   # - unparam
-  # - whitespace
+    - whitespace
   disable:
     - errcheck
     - gosimple
diff --git a/example/commitpr/main.go b/example/commitpr/main.go
index 61a39318..f437c84d 100644
--- a/example/commitpr/main.go
+++ b/example/commitpr/main.go
@@ -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
diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go
index d756fcd4..86921bae 100644
--- a/github/actions_workflow_jobs.go
+++ b/github/actions_workflow_jobs.go
@@ -147,5 +147,4 @@ func (s *ActionsService) getWorkflowLogsFromURL(ctx context.Context, u string, f
 		resp, err = s.getWorkflowLogsFromURL(ctx, u, false)
 	}
 	return resp, err
-
 }
diff --git a/github/github.go b/github/github.go
index a2727ccf..d4d7a54a 100644
--- a/github/github.go
+++ b/github/github.go
@@ -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
 	}
@@ -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
 	}
 
@@ -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
@@ -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
diff --git a/github/messages.go b/github/messages.go
index 01c8b12c..4a03890c 100644
--- a/github/messages.go
+++ b/github/messages.go
@@ -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
diff --git a/github/repos_contents.go b/github/repos_contents.go
index d88ae74b..86e11c0a 100644
--- a/github/repos_contents.go
+++ b/github/repos_contents.go
@@ -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 {
@@ -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
@@ -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 {
@@ -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


Test patch:
diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go
index 14274d53..6803ace0 100644
--- a/github/actions_workflow_runs_test.go
+++ b/github/actions_workflow_runs_test.go
@@ -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}}
diff --git a/github/enterprise_audit_log_test.go b/github/enterprise_audit_log_test.go
index 9f6f4a85..2e91346e 100644
--- a/github/enterprise_audit_log_test.go
+++ b/github/enterprise_audit_log_test.go
@@ -96,5 +96,4 @@ func TestEnterpriseService_GetAuditLog(t *testing.T) {
 		}
 		return resp, err
 	})
-
 }
diff --git a/github/github_test.go b/github/github_test.go
index e92dbb66..08d2c8ad 100644
--- a/github/github_test.go
+++ b/github/github_test.go
@@ -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)
 			}
@@ -2028,7 +2028,6 @@ func TestAddOptions_QueryValues(t *testing.T) {
 }
 
 func TestBareDo_returnsOpenBody(t *testing.T) {
-
 	client, mux, _, teardown := setup()
 	defer teardown()
 
diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go
index 1121ffd2..95b0a0cf 100644
--- a/github/orgs_audit_log_test.go
+++ b/github/orgs_audit_log_test.go
@@ -110,7 +110,6 @@ func TestOrganizationService_GetAuditLog(t *testing.T) {
 		}
 		return resp, err
 	})
-
 }
 
 func TestGetAuditLogOptions_Marshal(t *testing.T) {
diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go
index 442ae13e..adc14f5b 100644
--- a/github/orgs_members_test.go
+++ b/github/orgs_members_test.go
@@ -655,7 +655,6 @@ func TestOrganizationsService_CreateOrgInvitation(t *testing.T) {
 		}
 
 		fmt.Fprintln(w, `{"email": "octocat@github.com"}`)
-
 	})
 
 	ctx := context.Background()
diff --git a/github/orgs_test.go b/github/orgs_test.go
index fe34a5a0..b30c48f1 100644
--- a/github/orgs_test.go
+++ b/github/orgs_test.go
@@ -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) {
diff --git a/github/repos_test.go b/github/repos_test.go
index 4bb6be22..4c799048 100644
--- a/github/repos_test.go
+++ b/github/repos_test.go
@@ -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)
@@ -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 {