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 does not understand trailing until #8864

Closed
nertzy opened this issue Oct 8, 2020 · 1 comment · Fixed by #8866
Closed

Style/RedundantBegin does not understand trailing until #8864

nertzy opened this issue Oct 8, 2020 · 1 comment · Fixed by #8866
Labels

Comments

@nertzy
Copy link

nertzy commented Oct 8, 2020

Style/RedundantBegin does not understand this valid example:

begin
  do_first_thing
  some_value = do_second_thing
end until some_value

Expected behavior

Rubocop should not flag this as an error

Actual behavior

It is flagged by Style/RedundantBegin.

Using auto-correct gives:

  do_first_thing
  some_value = do_second_thing
 until some_value
$ bundle exec rubocop --debug tmp/foo.rb
For /Users/dev/projects/syrup: configuration from /Users/dev/projects/syrup/.rubocop.yml
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop.yml
Default configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-0.93.0/config/default.yml
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop_performance.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-performance-1.8.1/config/default.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-performance-1.8.1/config/default.yml
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop_rails.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.1/config/default.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.1/config/default.yml
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop_rake.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rake-0.5.1/config/default.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rake-0.5.1/config/default.yml
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop_rspec.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rspec-1.43.2/config/default.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rspec-1.43.2/config/default.yml
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop_thread_safety.yml
configuration from /Users/dev/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-thread_safety-0.4.1/config/default.yml
configuration from #{path}
Inheriting configuration from /Users/dev/projects/groundwork-style/rubocop_i18n.yml
.rubocop.yml: RSpec/ExampleLength:Exclude overrides the same parameter in /Users/dev/projects/groundwork-style/rubocop_rails.yml
.rubocop.yml: RSpec/MultipleExpectations:Exclude overrides the same parameter in /Users/dev/projects/groundwork-style/rubocop_rails.yml
.rubocop.yml: AllCops:Include overrides the same parameter in /Users/dev/projects/groundwork-style/rubocop_rspec.yml
.rubocop.yml: Rails/SquishedSQLHeredocs:Enabled overrides the same parameter in /Users/dev/projects/groundwork-style/rubocop_rspec.yml
.rubocop.yml: Style/MethodCalledOnDoEndBlock:Enabled overrides the same parameter in /Users/dev/projects/groundwork-style/rubocop_i18n.yml
Inspecting 1 file
Scanning /Users/dev/projects/syrup/tmp/foo.rb
C

Offenses:

tmp/foo.rb:3:1: C: Style/RedundantBegin: Redundant begin block detected.
begin
^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable
Finished in 0.48552500002551824 seconds

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

$ bundle exec rubocop -V
0.93.0 (using Parser 2.7.1.5, rubocop-ast 0.7.1, running on ruby 2.7.2 x86_64-darwin19)```
@koic koic added the bug label Oct 8, 2020
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 8, 2020
@koic koic closed this as completed in #8866 Oct 9, 2020
koic added a commit that referenced this issue Oct 9, 2020
[Fix #8864] Fix false positive for `Style/RedundantBegin` with a postfix `while` or `until`
@nertzy
Copy link
Author

nertzy commented Oct 14, 2020

Thanks! 😄

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