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 #12394] Fix false negatives for Style/RedundantReturn #12395

Merged

Conversation

koic
Copy link
Member

@koic koic commented Nov 16, 2023

Fixes #12394.

This PR fixes false negatives for Style/RedundantReturn when lambda, ->, or proc ending with return.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • 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.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

Fixes rubocop#12394.

This PR fixes false negatives for `Style/RedundantReturn`
when `lambda`, `->`, or `proc` ending with `return`.
@koic koic merged commit 5ccf58a into rubocop:master Nov 16, 2023
28 checks passed
@koic koic deleted the fix_false_negatives_for_style_redundant_return branch November 16, 2023 15:17
@Math2
Copy link

Math2 commented Nov 16, 2023

Hey I don't think proc should have been included with it. A return from a proc returns from the enclosing method/lambda, not the proc itself. It is not redundant, it has different semantics.

koic added a commit that referenced this pull request Nov 17, 2023
Follow up #12395 (comment).

This PR fixes false positive for `Style/RedundantReturn`
when `proc` ending with `return`.
@koic
Copy link
Member Author

koic commented Nov 17, 2023

@Math2 You're right! I've fixed the false positive in 2b27768. Thank you for your early feedback!

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.

Improve Style/RedundantReturn cop for lambdas
2 participants