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

Make Style/RedundantBegin aware of begin without rescue #8822

Conversation

koic
Copy link
Member

@koic koic commented Sep 30, 2020

This PR makes Style/RedundantBegin aware of begin without rescue or ensure.

I got the inspiration below.
faker-ruby/faker#1988


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the make_style_redundant_begin_aware_of_begin_without_rescue branch 2 times, most recently from 32af4ae to 94b9d43 Compare September 30, 2020 18:51
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 1, 2020

I think you should also update the examples in the cop's documentation.

@koic koic force-pushed the make_style_redundant_begin_aware_of_begin_without_rescue branch from 94b9d43 to 432f3ff Compare October 1, 2020 16:55
@koic
Copy link
Member Author

koic commented Oct 1, 2020

Sure! I added the example of new target to the cop's document.

This PR makes `Style/RedundantBegin` aware of `begin` without `rescue`
or `ensure`.

I got the inspiration below.
faker-ruby/faker#1988
@koic koic force-pushed the make_style_redundant_begin_aware_of_begin_without_rescue branch from 432f3ff to 7b94b88 Compare October 5, 2020 16:49
@koic koic merged commit d4ce6ce into rubocop:master Oct 5, 2020
@koic koic deleted the make_style_redundant_begin_aware_of_begin_without_rescue branch October 5, 2020 17:08
koic added a commit to koic/rubocop that referenced this pull request Oct 9, 2020
Fixes rubocop#8871.

This PR fixes a false positive for `Style/RedundantBegin`
when using `begin` for method argument or part of conditions.

`begin` keyword may be redundant when using only one expression
in `begin` of each issue case.
However, since it is the unintended case for rubocop#8822, I think it
can be implemented as an enhancement different from this bug fix.
bbatsov pushed a commit that referenced this pull request Oct 9, 2020
Fixes #8871.

This PR fixes a false positive for `Style/RedundantBegin`
when using `begin` for method argument or part of conditions.

`begin` keyword may be redundant when using only one expression
in `begin` of each issue case.
However, since it is the unintended case for #8822, I think it
can be implemented as an enhancement different from this bug fix.
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.

None yet

2 participants