Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #7033. This PR fixes an error for `Layout/EmptyLineAfterGuardClause` when guard clause is a ternary operator. The following is a reproduction step. ```console % rubocop -V 0.68.1 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin17) % cat example.rb def foo puts 'some action happens here' rescue => e a_check ? raise(e) : other_thing true end % rubocop --only Layout/EmptyLineAfterGuardClause -d For /private/tmp/7033: configuration from /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.68.1/config/default.yml Inspecting 1 file Scanning /private/tmp/7033/example.rb An error occurred while Layout/EmptyLineAfterGuardClause cop was inspecting /private/tmp/7033/example.rb:4:2. undefined method `end' for #<Parser::Source::Map::Ternary:0x00007fd3be9fca10> Did you mean? send /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.68.1/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb:133:in `offense_location' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.68.1/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb:56:in `on_if' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.68.1/lib/rubocop/cop/commissioner.rb:59:in `block (2 levels) in trigger_responding_cops' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.68.1/lib/rubocop/cop/commissioner.rb:130:in `with_cop_error_handling' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.68.1/lib/rubocop/cop/commissioner.rb:58:in `block in trigger_responding_cops' (snip) 1 file inspected, no offenses detected 1 error occurred: An error occurred while Layout/EmptyLineAfterGuardClause cop was inspecting /private/tmp/7033/example.rb:4:2. Errors are usually caused by RuboCop bugs. Please, report your problems to RuboCop's issue tracker. https://github.com/rubocop-hq/rubocop/issues Mention the following information in the issue report: 0.68.1 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin17) Finished in 0.7535030001308769 seconds ```
- Loading branch information