Skip to content

refactor!: Do not capitalize error strings #3446

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

Merged
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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ linters-settings:
errorf: true
strconcat: false
revive:
# Set below 0.8 to enable error-strings rule.
confidence: 0.6
rules:
- name: blank-imports
- name: bool-literal-in-expr
Expand Down
4 changes: 2 additions & 2 deletions example/codespaces/newreposecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
}

if _, err := client.Codespaces.CreateOrUpdateRepoSecret(ctx, owner, repo, encryptedSecret); err != nil {
return fmt.Errorf("Codespaces.CreateOrUpdateRepoSecret returned error: %v", err)
return fmt.Errorf("client.Codespaces.CreateOrUpdateRepoSecret returned error: %v", err)

Check warning on line 137 in example/codespaces/newreposecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newreposecretwithxcrypto/main.go#L137

Added line #L137 was not covered by tests
}

return nil
Expand All @@ -143,7 +143,7 @@
func encryptSecretWithPublicKey(publicKey *github.PublicKey, secretName string, secretValue string) (*github.EncryptedSecret, error) {
decodedPublicKey, err := base64.StdEncoding.DecodeString(publicKey.GetKey())
if err != nil {
return nil, fmt.Errorf("base64.StdEncoding.DecodeString was unable to decode public key: %v", err)
return nil, fmt.Errorf("unable to decode public key: %v", err)

Check warning on line 146 in example/codespaces/newreposecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newreposecretwithxcrypto/main.go#L146

Added line #L146 was not covered by tests
}

var boxKey [32]byte
Expand Down
6 changes: 3 additions & 3 deletions example/codespaces/newusersecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@
}

if _, err := client.Codespaces.CreateOrUpdateUserSecret(ctx, encryptedSecret); err != nil {
return fmt.Errorf("Codespaces.CreateOrUpdateUserSecret returned error: %v", err)
return fmt.Errorf("client.Codespaces.CreateOrUpdateUserSecret returned error: %v", err)

Check warning on line 132 in example/codespaces/newusersecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newusersecretwithxcrypto/main.go#L132

Added line #L132 was not covered by tests
}

if owner != "" && repo != "" {
r, _, err := client.Repositories.Get(ctx, owner, repo)
if err != nil {
return fmt.Errorf("Repositories.Get returned error: %v", err)
return fmt.Errorf("client.Repositories.Get returned error: %v", err)

Check warning on line 138 in example/codespaces/newusersecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newusersecretwithxcrypto/main.go#L138

Added line #L138 was not covered by tests
}
_, err = client.Codespaces.AddSelectedRepoToUserSecret(ctx, encryptedSecret.Name, r)
if err != nil {
return fmt.Errorf("Codespaces.AddSelectedRepoToUserSecret returned error: %v", err)
return fmt.Errorf("client.Codespaces.AddSelectedRepoToUserSecret returned error: %v", err)

Check warning on line 142 in example/codespaces/newusersecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newusersecretwithxcrypto/main.go#L142

Added line #L142 was not covered by tests
}
fmt.Printf("Added secret %q to %v/%v\n", secretName, owner, repo)
}
Expand Down
2 changes: 1 addition & 1 deletion example/newreposecretwithlibsodium/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func addRepoSecret(ctx context.Context, client *github.Client, owner string, rep
}

if _, err := client.Actions.CreateOrUpdateRepoSecret(ctx, owner, repo, encryptedSecret); err != nil {
return fmt.Errorf("Actions.CreateOrUpdateRepoSecret returned error: %v", err)
return fmt.Errorf("client.Actions.CreateOrUpdateRepoSecret returned error: %v", err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion example/newreposecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
}

if _, err := client.Actions.CreateOrUpdateRepoSecret(ctx, owner, repo, encryptedSecret); err != nil {
return fmt.Errorf("Actions.CreateOrUpdateRepoSecret returned error: %v", err)
return fmt.Errorf("client.Actions.CreateOrUpdateRepoSecret returned error: %v", err)

Check warning on line 137 in example/newreposecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/newreposecretwithxcrypto/main.go#L137

Added line #L137 was not covered by tests
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func WithVersion(version string) RequestOption {
// request body.
func (c *Client) NewRequest(method, urlStr string, body interface{}, opts ...RequestOption) (*http.Request, error) {
if !strings.HasSuffix(c.BaseURL.Path, "/") {
return nil, fmt.Errorf("BaseURL must have a trailing slash, but %q does not", c.BaseURL)
return nil, fmt.Errorf("baseURL must have a trailing slash, but %q does not", c.BaseURL)
}

u, err := c.BaseURL.Parse(urlStr)
Expand Down Expand Up @@ -565,7 +565,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}, opts ...Req
// Body is sent with Content-Type: application/x-www-form-urlencoded.
func (c *Client) NewFormRequest(urlStr string, body io.Reader, opts ...RequestOption) (*http.Request, error) {
if !strings.HasSuffix(c.BaseURL.Path, "/") {
return nil, fmt.Errorf("BaseURL must have a trailing slash, but %q does not", c.BaseURL)
return nil, fmt.Errorf("baseURL must have a trailing slash, but %q does not", c.BaseURL)
}

u, err := c.BaseURL.Parse(urlStr)
Expand Down Expand Up @@ -597,7 +597,7 @@ func (c *Client) NewFormRequest(urlStr string, body io.Reader, opts ...RequestOp
// Relative URLs should always be specified without a preceding slash.
func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string, opts ...RequestOption) (*http.Request, error) {
if !strings.HasSuffix(c.UploadURL.Path, "/") {
return nil, fmt.Errorf("UploadURL must have a trailing slash, but %q does not", c.UploadURL)
return nil, fmt.Errorf("uploadURL must have a trailing slash, but %q does not", c.UploadURL)
}
u, err := c.UploadURL.Parse(urlStr)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ func TestErrorResponse_Is(t *testing.T) {
},
"errors have different types": {
wantSame: false,
otherError: errors.New("Github"),
otherError: errors.New("github"),
},
}

Expand Down Expand Up @@ -2250,7 +2250,7 @@ func TestRateLimitError_Is(t *testing.T) {
"errors have different types": {
wantSame: false,
err: err,
otherError: errors.New("Github"),
otherError: errors.New("github"),
},
}

Expand Down Expand Up @@ -2337,7 +2337,7 @@ func TestAbuseRateLimitError_Is(t *testing.T) {
"errors have different types": {
wantSame: false,
err: err,
otherError: errors.New("Github"),
otherError: errors.New("github"),
},
}

Expand Down Expand Up @@ -2369,7 +2369,7 @@ func TestAcceptedError_Is(t *testing.T) {
},
"errors have different types": {
wantSame: false,
otherError: errors.New("Github"),
otherError: errors.New("github"),
},
}

Expand Down
2 changes: 1 addition & 1 deletion github/repos_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error {
default:
r.Type = ""
r.Parameters = nil
return fmt.Errorf("RepositoryRule.Type %q is not yet implemented, unable to unmarshal (%#v)", repositoryRule.Type, repositoryRule)
return fmt.Errorf("repositoryRule.Type %q is not yet implemented, unable to unmarshal (%#v)", repositoryRule.Type, repositoryRule)
}

return nil
Expand Down
Loading