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 an error for Layout/EmptyLinesAroundExceptionHandlingKeywords #10193

Commits on Oct 17, 2021

  1. Fix an error for Layout/EmptyLinesAroundExceptionHandlingKeywords

    This PR fixes the following error for `Layout/EmptyLinesAroundExceptionHandlingKeywords`
    when `begin` and `rescue` are on the same line.
    
    ```console
    % echo 'begin; foo; rescue => e; end' | bundle exec rubocop --stdin
      example.rb -d
    For /Users/koic/src/github.com/rubocop/rubocop: configuration from
      /Users/koic/src/github.com/rubocop/rubocop/.rubocop.yml
    configuration from
      /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/rubocop-performance-1.11.5/config/default.yml
    configuration from
      /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/rubocop-performance-1.11.5/config/default.yml
    Default configuration from
      /Users/koic/src/github.com/rubocop/rubocop/config/default.yml
    configuration from
      /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/rubocop-rspec-2.5.0/config/default.yml
    configuration from
      /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/rubocop-rspec-2.5.0/config/default.yml
    configuration from
      /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/rubocop-rake-0.6.0/config/default.yml
    configuration from
      /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/rubocop-rake-0.6.0/config/default.yml
    Inheriting configuration from
      /Users/koic/src/github.com/rubocop/rubocop/.rubocop_todo.yml
    Inspecting 1 file
    Scanning /Users/koic/src/github.com/rubocop/rubocop/example.rb
    An error occurred while Layout/EmptyLinesAroundExceptionHandlingKeywords
      cop was inspecting
      /Users/koic/src/github.com/rubocop/rubocop/example.rb:1:0.
    The range 29...30 is outside the bounds of the source
    /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/parser-3.0.2.0/lib/parser/source/tree_rewriter.rb:406:in
      `check_range_validity'
    /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/corrector.rb:100:in
      `check_range_validity'
    /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/parser-3.0.2.0/lib/parser/source/tree_rewriter.rb:398:in
      `combine'
    /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/parser-3.0.2.0/lib/parser/source/tree_rewriter.rb:194:in
      `replace'
    /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/gems/3.1.0/gems/parser-3.0.2.0/lib/parser/source/tree_rewriter.rb:218:in
      `remove'
    /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/correctors/empty_line_corrector.rb:13:in
      `correct'
    /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/mixin/empty_lines_around_body.rb:104:in
      `block in check_line'
    /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/base.rb:342:in
      `correct'
    /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/base.rb:127:in `add_offense'
    ```
    koic committed Oct 17, 2021
    Copy the full SHA
    95262d0 View commit details
    Browse the repository at this point in the history