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

Style/RedundantBegin – false positive when calling a method on the block end #8869

Closed
bquorning opened this issue Oct 9, 2020 · 0 comments · Fixed by #8870
Closed

Style/RedundantBegin – false positive when calling a method on the block end #8869

bquorning opened this issue Oct 9, 2020 · 0 comments · Fixed by #8870
Labels

Comments

@bquorning
Copy link
Contributor

In v0.93.0, Style/RedundantBegin started taking an offense with this code:

# frozen_string_literal: true

@memo ||= begin
  this
  that
end.foo do
  other_thing
end

Expected behavior

No offenses.

Actual behavior

test.rb:3:11: C: Style/RedundantBegin: Redundant begin block detected.
@memo ||= begin
          ^^^^^

Steps to reproduce the problem

On the RuboCop repository:

git checkout v0.93.0 && \
echo '# frozen_string_literal: true

@memo ||= begin
  this
  that
end.foo do
  other_thing
end' > test.rb && \
./exe/rubocop test.rb

RuboCop version

$ ./exe/rubocop -V
0.93.0 (using Parser 2.7.1.5, rubocop-ast 0.7.1, running on ruby 2.6.6 x86_64-darwin19)
@bquorning bquorning changed the title Style/RedundantBegin – false positive when calling e.g. tap on block Style/RedundantBegin – false positive when calling a method on the block end Oct 9, 2020
@koic koic added the bug label Oct 9, 2020
koic added a commit to koic/rubocop that referenced this issue Oct 9, 2020
Fixes rubocop#8869.

This PR fixes a false positive for `Style/RedundantBegin`
when using `begin` for or assignment and method call.
bbatsov pushed a commit that referenced this issue Oct 9, 2020
Fixes #8869.

This PR fixes a false positive for `Style/RedundantBegin`
when using `begin` for or assignment and method call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants