Skip to content

Style/RendundantBegin could eliminate multiline begin blocks in branches #14453

@jaynetics

Description

@jaynetics

Is your feature request related to a problem? Please describe.

It would be cool if cases like the following were auto-corrected.

$ cat examples.rb
case 1 + 1
when 2
  begin
    puts 'hello'
    puts 'goodbye'
  end
end

if 1 + 1 == 2
  begin
    puts 'hello'
    puts 'goodbye'
  end
end
$ rubocop --only Style/RedundantBegin -a examples.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

I couldn't think of a case where auto-correcting such a case would cause issues - or am I missing something?

Additional context

I'm interested in this because I have code in the regexp_parser gem that is generated by ragel, and ragel generates lots of these cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions