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

refactor!: Do not capitalize error strings #3446

Merged

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Jan 21, 2025

BREAKING CHANGE: Some error strings are slightly modified - please do not rely on error text in general.

This PR is somewhat of a breaking change because it changes error messages for Client.NewRequest, Client.NewFormRequest, and Client.NewUploadRequest. However, I'm not sure if anyone relies on the word case of an error message.

The PR also configures golangci-lint to detect this in the future.
revive.error-strings was already enabled in the lint config but didn't work until we set confidence: 0.6 in this PR.

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 92.26%. Comparing base (b8c2253) to head (c6417f8).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...xample/codespaces/newusersecretwithxcrypto/main.go 0.00% 3 Missing ⚠️
...xample/codespaces/newreposecretwithxcrypto/main.go 0.00% 2 Missing ⚠️
example/newreposecretwithxcrypto/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3446   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files         174      174           
  Lines       15023    15023           
=======================================
  Hits        13861    13861           
  Misses       1068     1068           
  Partials       94       94           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jan 21, 2025
@gmlewis gmlewis changed the title refactor: Do not capitalize error strings refactor!: Do not capitalize error strings Jan 21, 2025
@gmlewis gmlewis added the Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). label Jan 21, 2025
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @alexandear.
Although this is not technically a breaking change in the sense that older code will not compile correctly, if users of the package parse error strings (which they should NOT), then it would silently break them if we didn't call it out.
So as a user of this library, I would much rather know about a potential breakage to my code than to let this silently slip by unnoticed.
Therefore, let's be pedantic and call this out as "breaking" so it is visible.
Also, we have a bunch of other breaking API changes upcoming in the next major release, so now is as good a time as any to make these changes.

And just for the record, this is one of my LEAST favorite lint requirements and rules about idiomatic Go, because in a big code base, I like to see which function is returning the error message and I want to put the function's name into the error which sometimes starts with a capital. Ah well, I understand about the wrapping of errors and why it was done this way, yet still it can be my least favorite thing about Go.
Also for the record, Go is still my favorite programming language and the one I reach for when starting a new serious project or a quick script, but MoonBit is quickly shaping up to be a strong contender. 😂

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@stevehipwell - might you have time for a code review? Thanks!

Copy link
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Jan 21, 2025
@gmlewis
Copy link
Collaborator

gmlewis commented Jan 21, 2025

Thank you, @stevehipwell !
Merging.

@gmlewis gmlewis merged commit 1875fe0 into google:master Jan 21, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants