-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: use errors.New
to replace fmt.Errorf
with no parameters
#21394
Conversation
WalkthroughWalkthroughThe changes involve an update in error handling across multiple files in the codebase, replacing the use of Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
server/v2/store/snapshot.go (1)
340-345
: Consider optimizing snapshot comparison.Using
reflect.DeepEqual
for comparing large or complex snapshots might be inefficient. If performance is a concern, consider implementing a more efficient comparison method specific to the snapshot's structure.
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (7)
- schema/appdata/async_test.go (3 hunks)
- server/v2/stf/util.go (2 hunks)
- server/v2/store/snapshot.go (1 hunks)
- store/v2/root/factory.go (1 hunks)
- store/v2/root/store.go (2 hunks)
- x/distribution/keeper/validator.go (2 hunks)
- x/genutil/genesis.go (2 hunks)
Files skipped from review due to trivial changes (3)
- server/v2/stf/util.go
- store/v2/root/store.go
- x/genutil/genesis.go
Additional context used
Path-based instructions (4)
schema/appdata/async_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"store/v2/root/factory.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/distribution/keeper/validator.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/store/snapshot.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (6)
schema/appdata/async_test.go (2)
81-81
: Approved change to error handling inCommit
method.The replacement of
fmt.Errorf
witherrors.New
is consistent with the PR's objective to standardize error handling. The change is straightforward and does not introduce any new issues.
144-144
: Approved change to error handling inOnKVPair
method.The change from
fmt.Errorf
toerrors.New
is appropriate and aligns with the PR's goal of simplifying error creation. The new error handling is correctly implemented.store/v2/root/factory.go (2)
142-142
: Approved change to error handling for unsupportedSCType
.The change from
fmt.Errorf
toerrors.New
is consistent with the PR's objective. The new error handling method enhances clarity and maintains the semantic meaning of the error.
144-144
: Approved change to error handling for unsupported store type.This change simplifies the error creation process and aligns with the PR's goal of standardizing error handling. The implementation is correct and does not introduce any new issues.
x/distribution/keeper/validator.go (1)
148-148
: Approved change to error handling indecrementReferenceCount
.The replacement of
fmt.Errorf
witherrors.New
for handling zero reference count is appropriate and aligns with the PR's objective of simplifying error creation. The implementation is correct and does not introduce any new issues.server/v2/store/snapshot.go (1)
340-340
: Approved changes fromfmt.Errorf
toerrors.New
.The changes correctly replace formatted error messages with simpler ones where no formatting parameters are used, aligning with the PR's objectives.
Also applies to: 345-345
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (7)
- schema/appdata/async_test.go (3 hunks)
- server/v2/stf/util.go (2 hunks)
- server/v2/store/snapshot.go (1 hunks)
- store/v2/root/factory.go (1 hunks)
- store/v2/root/store.go (2 hunks)
- x/distribution/keeper/validator.go (2 hunks)
- x/genutil/genesis.go (2 hunks)
Files skipped from review due to trivial changes (6)
- server/v2/stf/util.go
- server/v2/store/snapshot.go
- store/v2/root/factory.go
- store/v2/root/store.go
- x/distribution/keeper/validator.go
- x/genutil/genesis.go
Additional context used
Path-based instructions (1)
schema/appdata/async_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (2)
schema/appdata/async_test.go (2)
81-81
: Refactor toerrors.New
is appropriate for static error messages.The change from
fmt.Errorf
toerrors.New
is consistent with the PR's objective to simplify error creation when no formatting is needed. This enhances readability and maintainability.
144-144
: Refactor toerrors.New
is appropriate for static error messages.The change from
fmt.Errorf
toerrors.New
is consistent with the PR's objective to simplify error creation when no formatting is needed. This enhances readability and maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (7)
- schema/appdata/async_test.go (3 hunks)
- server/v2/stf/util.go (2 hunks)
- server/v2/store/snapshot.go (1 hunks)
- store/v2/root/factory.go (1 hunks)
- store/v2/root/store.go (2 hunks)
- x/distribution/keeper/validator.go (2 hunks)
- x/genutil/genesis.go (2 hunks)
Files skipped from review due to trivial changes (3)
- server/v2/stf/util.go
- store/v2/root/factory.go
- x/genutil/genesis.go
Additional context used
Path-based instructions (4)
schema/appdata/async_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/distribution/keeper/validator.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/store/snapshot.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.store/v2/root/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (8)
schema/appdata/async_test.go (2)
81-81
: Approved change to error handling inCommit
.The use of
errors.New
is appropriate for static error messages, enhancing code clarity.
144-144
: Approved change to error handling inOnKVPair
.Switching to
errors.New
for static error messages is a good practice for improving readability.x/distribution/keeper/validator.go (1)
148-148
: Approved change to error handling indecrementReferenceCount
.Using
errors.New
for static error messages simplifies the error creation process and enhances code clarity.server/v2/store/snapshot.go (2)
340-340
: Approved change to error handling inLoadArchiveCmd
.The transition to
errors.New
for static error messages is appropriate and improves code clarity.
345-345
: Approved change to error handling inLoadArchiveCmd
.Using
errors.New
for static error messages is consistent with the PR's objectives and enhances readability.store/v2/root/store.go (3)
248-248
: Approved replacement offmt.Errorf
witherrors.New
.The change correctly replaces
fmt.Errorf
witherrors.New
for a static error message, aligning with the PR's objectives.
256-256
: Approved replacement offmt.Errorf
witherrors.New
.This change is consistent with the PR's goal of using
errors.New
for static error messages.
286-286
: Approved replacement offmt.Errorf
witherrors.New
.The change correctly replaces
fmt.Errorf
witherrors.New
for a static error message, aligning with the PR's objectives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- x/distribution/keeper/validator.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- x/distribution/keeper/validator.go
Description
Similar to #20943
Summary by CodeRabbit
Bug Fixes
Chores
fmt.Errorf
witherrors.New
throughout the codebase for enhanced readability and maintainability.