Skip to content

Commit

Permalink
Use RescueNode#resbody_branches
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima authored and mergify[bot] committed Sep 17, 2020
1 parent 001ddc1 commit aa7d8d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
Expand Up @@ -91,9 +91,7 @@ def on_case(node)
end

def on_rescue(node)
_body, *resbodies, _else = *node

resbodies.each do |resbody|
node.resbody_branches.each do |resbody|
rescued_exceptions = resbody.exceptions
next if !multiline_rescue_exceptions?(rescued_exceptions) ||
next_line_empty?(rescued_exceptions.last.last_line)
Expand Down
Expand Up @@ -113,10 +113,9 @@ def keyword_locations(node)
end

def keyword_locations_in_rescue(node)
_begin_body, *resbodies, _else_body = *node
[
node.loc.else,
*resbodies.map { |body| body.loc.keyword }
*node.resbody_branches.map { |body| body.loc.keyword }
].compact
end

Expand Down
4 changes: 1 addition & 3 deletions lib/rubocop/cop/lint/duplicate_rescue_exception.rb
Expand Up @@ -33,9 +33,7 @@ class DuplicateRescueException < Base
def on_rescue(node)
return if rescue_modifier?(node)

_body, *resbodies, _else = *node

resbodies.each_with_object(Set.new) do |resbody, previous|
node.resbody_branches.each_with_object(Set.new) do |resbody, previous|
rescued_exceptions = resbody.exceptions

rescued_exceptions.each do |exception|
Expand Down

0 comments on commit aa7d8d4

Please sign in to comment.