-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Remove panic from crdt.Tree and index.Tree #570
Conversation
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.
Thanks for your contribution.
I did 3 additional minor code cleanups below.
A. We can omit the error checking if the interface of return of caller and method are the same and called it at the end.
AS-IS
func (n *TreeNode) Append(newNodes ...*TreeNode) error {
// ...
err := n.IndexTreeNode.Append(indexNodes...)
if err != nil {
return err
}
return nil
}
TO-BE
func (n *TreeNode) Append(newNodes ...*TreeNode) error {
// ...
return n.IndexTreeNode.Append(indexNodes...)
}
B. We can shorten it by binding the error checking with the method call.
https://www.digitalocean.com/community/tutorials/handling-errors-in-go#handling-errors
C. I removed panic from buildDescendants, because it has an interface with an error return.
Codecov Report
@@ Coverage Diff @@
## main #570 +/- ##
==========================================
- Coverage 51.91% 51.31% -0.61%
==========================================
Files 67 67
Lines 6851 6949 +98
==========================================
+ Hits 3557 3566 +9
- Misses 2855 2915 +60
- Partials 439 468 +29
|
What this PR does / why we need it:
Which issue(s) this PR fixes:
Related to #497
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist: