Rubocop: `Layout/RescueEnsureAlignment` issue with `proc` using embedded `rescue`

Created on 6 Dec 2018  路  6Comments  路  Source: rubocop-hq/rubocop

Expected behavior

No error ;)

Actual behavior

Error:
An error occurred while Layout/RescueEnsureAlignment cop was inspecting /Users/cheerfulstoic/github/fishbrain/rutilus-api.side/test.rb:4:2.

Mention the following information in the issue report:
0.61.1 (using Parser 2.5.3.0, running on ruby 2.5.3 x86_64-linux)

Steps to reproduce the problem

A file with just this code fails:

utc_zone_parse =
  proc do |datetime_string|
    utc_zone.parse(datetime_string)
  rescue ArgumentError
    raise "Date/time string was in an invalid format: #{datetime_string}", nil
  end

This doesn't fail:

utc_zone_parse =
  proc do |datetime_string|
    begin
      utc_zone.parse(datetime_string)
    rescue ArgumentError
      raise "Date/time string was in an invalid format: #{datetime_string}", nil
    end
  end

RuboCop version

[dependabot/bundler/rubocop-0.61.1 !?] > bundle exec rubocop -V
0.61.1 (using Parser 2.5.3.0, running on ruby 2.5.3 x86_64-darwin17)
bug

Most helpful comment

Oh, looking closer I see it was closed via the commit (sorry, I was on my phone before). Look forward to 0.61.2 ;)

All 6 comments

Same with

runtime_info =
  Timeout.timeout(5) do
    maintenance_task.vhost.runtime_info
   rescue StandardError
     false
  end

0.61.1 (using Parser 2.5.3.0, running on ruby 2.5.1 x86_64-linux-gnu)

Seems like there's a deeper problem than what #6552 addresses. No longer sure that is the correct location for a fix. 馃

I also get this error for the following code:

valid = begin
          URI.parse(value).is_a?(URI::HTTP)
        rescue URI::InvalidURIError
          false
        end

I have more examples if needed.

_EDIT_: We are on Ruby 2.4.4 with Rubocop 0.61.0

I also get this error for the following code

This is already fixed in 0.61.1 which has been cut and released. 馃檪

My original issue was using 0.61.1 though... I don鈥檛 think this is resolved yet... I see the CHANGELOG about the new fix, but it doesn鈥檛 seem to be released yet

Oh, looking closer I see it was closed via the commit (sorry, I was on my phone before). Look forward to 0.61.2 ;)

Was this page helpful?
0 / 5 - 0 ratings