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

chore(go): fixed deepsource issues #3

Merged
merged 1 commit into from
Mar 12, 2024
Merged

chore(go): fixed deepsource issues #3

merged 1 commit into from
Mar 12, 2024

Conversation

cnlangzi
Copy link
Member

Fixes

  • fixed warnings from deepsource report.

Copy link
Contributor

deepsource-io bot commented Mar 12, 2024

Here's the code health analysis summary for commits 865a3e5..42cf979. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Go LogoGo✅ Success
🎯 18 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

@sourcery-ai sourcery-ai bot left a 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? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -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)
Copy link

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.

Suggested change
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() },
Copy link

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.

Suggested change
ctx: func() context.Context { return context.Background() },
ctx: context.Background(),

@cnlangzi cnlangzi merged commit 8b90486 into main Mar 12, 2024
6 checks passed
@cnlangzi cnlangzi deleted the fix/deepsource branch March 12, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant