-
Notifications
You must be signed in to change notification settings - Fork 2
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
chore(go): fixed deepsource issues #3
Conversation
Here's the code health analysis summary for commits Analysis Summary
|
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.
Hey @cnlangzi - I've reviewed your changes and they look great!
General suggestions:
- Consider the broader impact of changing the return types and order on existing codebases that use this library, ensuring backward compatibility or providing a clear migration path.
- Review the simplification of context setup in test cases to ensure it does not affect the intention of the tests.
- Evaluate the performance implications of the early return in the
WaitN
method for various use cases to ensure it meets the needs of all consumers.
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Docstrings: all looks good
Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨
@@ -8,11 +8,11 @@ type Awaiter[T any] interface { | |||
// Add add a task | |||
Add(task func(context.Context) (T, error)) | |||
// Wait wail for all tasks to completed | |||
Wait(context.Context) ([]T, error, []error) |
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.
suggestion (code_refinement): Changing the order of return types for the Wait
, WaitAny
, and WaitN
methods improves consistency with Go's conventional error handling, where the error is typically the last return value. This change enhances readability and aligns with common Go practices.
Wait(context.Context) ([]T, error, []error) | |
// Wait waits for all tasks to be completed. It returns a slice of results, a slice of errors for individual tasks that failed, and an error if the waiting process itself encounters an error. | |
Wait(context.Context) ([]T, []error, error) |
@@ -26,7 +26,7 @@ func TestWait(t *testing.T) { | |||
}{ | |||
{ | |||
name: "wait_should_work", | |||
ctx: func() context.Context { return context.Background() }, |
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.
suggestion (code_refinement): Simplifying the ctx
field in test cases by directly assigning context.Background
instead of wrapping it in a function enhances clarity and reduces unnecessary complexity. This change makes the test setup more straightforward.
ctx: func() context.Context { return context.Background() }, | |
ctx: context.Background(), |
Fixes