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

feat: add new ChopEnd and ChopStart string helpers #591

Merged
merged 6 commits into from
Aug 9, 2024

Conversation

shayan-yousefi
Copy link
Contributor

@shayan-yousefi shayan-yousefi commented Aug 8, 2024

📑 Description

In this pull request, I have added two new string helper methods, chopStart and chopEnd, to Goravel. These methods are inspired by the corresponding Laravel string helpers.

For more details, refer to the official Laravel documentation: String Helpers - chopStart and chopEnd.

Summary by CodeRabbit

  • New Features

    • Introduced ChopEnd method to remove specified strings from the end of a string.
    • Introduced ChopStart method to remove specified strings from the beginning of a string.
  • Tests

    • Added TestChopStart to validate the behavior of the ChopStart method.
    • Added TestChopEnd to validate the behavior of the ChopEnd method.

✅ Checks

  • Added test cases for my code

Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Warning

Rate limit exceeded

@shayan-yousefi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 33 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 63e4d80 and 799e7fd.

Walkthrough

The recent changes enhance the String struct by adding two new methods, ChopEnd and ChopStart, which allow for the removal of specified substrings from the beginning and end of a string, respectively. These methods improve the string manipulation capabilities of the struct, providing functionality to trim unwanted prefixes and suffixes efficiently. Additionally, corresponding unit tests have been introduced to ensure the reliability of these new methods.

Changes

Files Change Summary
support/str/str.go Added ChopEnd and ChopStart methods to the String struct for removing specified strings from the end and start of the string, respectively.
support/str/str_test.go Introduced TestChopStart and TestChopEnd test functions to validate the functionality of the new methods in various scenarios, enhancing test coverage.

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration 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.

@shayan-yousefi shayan-yousefi changed the title add new ChopEnd and ChopStart string helpers Feat: add new ChopEnd and ChopStart string helpers Aug 8, 2024
@shayan-yousefi shayan-yousefi changed the title Feat: add new ChopEnd and ChopStart string helpers feat: add new ChopEnd and ChopStart string helpers Aug 8, 2024
@shayan-yousefi shayan-yousefi reopened this Aug 8, 2024
@shayan-yousefi shayan-yousefi reopened this Aug 8, 2024
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.09%. Comparing base (e303e5b) to head (799e7fd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #591      +/-   ##
==========================================
+ Coverage   70.05%   70.09%   +0.03%     
==========================================
  Files         182      182              
  Lines       11288    11302      +14     
==========================================
+ Hits         7908     7922      +14     
  Misses       2805     2805              
  Partials      575      575              

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

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

They seem the same as LTrim and RTrim. Are they?

@shayan-yousefi
Copy link
Contributor Author

shayan-yousefi commented Aug 9, 2024

They seem the same as LTrim and RTrim. Are they?

ChopStart and ChopEnd can remove one or more strings from the left or right end, respectively, whereas Ltrim and Rtrim always remove a single string.

I committed another change to do trim with Golang's built-in TrimLeft and TrimRight functions.

edit:
they don't remove all strings passed, remove the first matched string, Ltrim and Rtrim always get "index: 0" and remove.

@shayan-yousefi shayan-yousefi requested a review from hwbrzzl August 9, 2024 06:09
@hwbrzzl
Copy link
Contributor

hwbrzzl commented Aug 9, 2024

Got it, one more question, I noticed this PR is going to merged to v1.14.x, but we only release new versions to fix bug. Do you have any special needs, please?

@shayan-yousefi
Copy link
Contributor Author

Got it, one more question, I noticed this PR is going to merged to v1.14.x, but we only release new versions to fix bug. Do you have any special needs, please?

May I be wrong? I read documentation for contribute, saw:
Minor features that are fully backward compatible with the current release may be sent to the latest stable branch.

But this was my question too, should I open it on the master?

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Aug 9, 2024

Sure, please use the master branch. Sorry for the confusion, I'll update the guide.

@shayan-yousefi shayan-yousefi changed the base branch from v1.14.x to master August 9, 2024 07:19
@shayan-yousefi shayan-yousefi requested a review from a team as a code owner August 9, 2024 07:19
@shayan-yousefi shayan-yousefi force-pushed the feat/add-chop-end-and-start branch from b2a23f3 to 2135878 Compare August 9, 2024 07:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e303e5b and 2135878.

Files selected for processing (2)
  • support/str/str.go (1 hunks)
  • support/str/str_test.go (1 hunks)
Additional comments not posted (2)
support/str/str_test.go (2)

1033-1039: Test cases for ChopStart are comprehensive and well-structured.

The test cases effectively cover various scenarios, ensuring the ChopStart method functions as expected.


1041-1047: Test cases for ChopEnd are comprehensive and well-structured.

The test cases effectively cover various scenarios, ensuring the ChopEnd method functions as expected.

support/str/str.go Outdated Show resolved Hide resolved
support/str/str.go Outdated Show resolved Hide resolved
@shayan-yousefi
Copy link
Contributor Author

Sure, please use the master branch. Sorry for the confusion, I'll update the guide.

thanks, I changed the base branch to master.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2135878 and 63e4d80.

Files selected for processing (1)
  • support/str/str.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • support/str/str.go

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 9, 2024
@kkumar-gcc
Copy link
Member

@shayan-yousefi It would be better if you can add these methods at their alphabetical position.

@shayan-yousefi
Copy link
Contributor Author

@shayan-yousefi It would be better if you can add these methods at their alphabetical position.

@kkumar-gcc done ✅

krishan-kumar-meesho

This comment was marked as outdated.

Copy link
Member

@kkumar-gcc kkumar-gcc left a comment

Choose a reason for hiding this comment

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

Great PR!! Thanks for your contribution.

@shayan-yousefi
Copy link
Contributor Author

They seem the same as LTrim and RTrim. Are they?

How can I resolve this? I can't see resolve button 😅

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Great PR 👍 Added you to the contributor list.

@hwbrzzl hwbrzzl merged commit 1814e7f into goravel:master Aug 9, 2024
10 checks passed
@hwbrzzl
Copy link
Contributor

hwbrzzl commented Aug 9, 2024

Looking forward to more PRs from you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants