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

fix: replace unwrap with Valid #1757

Closed
wants to merge 2 commits into from

Conversation

emekaokoli19
Copy link

@emekaokoli19 emekaokoli19 commented Apr 19, 2024

/claim #1739

#1739
Fixes #1739 fix: drop unwrap from from_proto

Build & Testing:

  • [ x] I ran cargo test successfully.
  • [ x] I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • [ x] I have performed a self-review of my code.
  • [ x] PR follows the naming convention of <type>(<optional scope>): <title>

Summary by CodeRabbit

  • Refactor
    • Improved error handling in data processing with the introduction of a new validation method.
    • Refined error handling and skipping logic in various parts of the code.

Copy link
Contributor

coderabbitai bot commented Apr 19, 2024

Walkthrough

Walkthrough

The update in the from_proto.rs file introduces a new Valid enum for robust error handling and replaces unwrap calls with safer alternatives. This change enhances the reliability and maintainability of the code by using Valid::from_iter for iterable checks and refining error handling throughout the file.

Changes

File Change Summary
.../from_proto.rs Introduced Valid enum for error handling, replaced unwrap with safer methods, refined error logic.

Assessment against linked issues

Objective Addressed Explanation
Drop unwrap from from_proto (#1739)
Use Valid type in from_proto (#1739)
Implement Valid::from_iter for iterable checks (#1739)

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 67fa7bf and 99402b2.
Files selected for processing (1)
  • src/generator/from_proto.rs (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/generator/from_proto.rs

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

algora-pbc bot commented Apr 19, 2024

💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe/Alipay.

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 19, 2024
@@ -23,6 +23,36 @@ struct Context {
query: String,
}

/// A custom enum representing either a valid value or an error.
#[derive(Debug)]
enum Valid<T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

actually valid is already defined in valid.rs we need to use that instead of defining a new one

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the delay, I have used the Valid in valid.rs

Copy link

codecov bot commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 78.57143% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 86.82%. Comparing base (2c5f9c4) to head (67fa7bf).
Report is 35 commits behind head on main.

❗ Current head 67fa7bf differs from pull request most recent head 99402b2. Consider uploading reports for the commit 99402b2 to get more accurate results

Files Patch % Lines
src/generator/from_proto.rs 78.57% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1757      +/-   ##
==========================================
- Coverage   86.93%   86.82%   -0.12%     
==========================================
  Files         155      155              
  Lines       15540    15583      +43     
==========================================
+ Hits        13510    13530      +20     
- Misses       2030     2053      +23     

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

Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Apr 21, 2024
@tusharmath tusharmath marked this pull request as draft April 23, 2024 05:00
@tusharmath
Copy link
Contributor

Moving to draft until the comments are fixed. Feel free to mark it as read for review whenever you are done fixing the comments.

@github-actions github-actions bot removed the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Apr 23, 2024
@emekaokoli19 emekaokoli19 marked this pull request as ready for review April 24, 2024 21:33
@tusharmath
Copy link
Contributor

@emekaokoli19 Appreciate your contributions but unfortunately, this PR isn't going in the right direction. Feel free to take help from the contributor's channel on discord and reopen it whenever you are ready.
Thanks once again!

@tusharmath tusharmath closed this Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: drop unwrap from from_proto
3 participants