lib/rubocop/cop/style/redundant_assignment.rb in rubocop-1.60.2 vs lib/rubocop/cop/style/redundant_assignment.rb in rubocop-1.61.0
- old
+ new
@@ -52,25 +52,33 @@
end
alias on_defs on_def
private
+ # rubocop:disable Metrics/CyclomaticComplexity
def check_branch(node)
return unless node
case node.type
- when :case then check_case_node(node)
- when :if then check_if_node(node)
+ when :case then check_case_node(node)
+ when :case_match then check_case_match_node(node)
+ when :if then check_if_node(node)
when :rescue, :resbody
check_rescue_node(node)
when :ensure then check_ensure_node(node)
when :begin, :kwbegin
check_begin_node(node)
end
end
+ # rubocop:enable Metrics/CyclomaticComplexity
def check_case_node(node)
node.when_branches.each { |when_node| check_branch(when_node.body) }
+ check_branch(node.else_branch)
+ end
+
+ def check_case_match_node(node)
+ node.in_pattern_branches.each { |in_pattern_node| check_branch(in_pattern_node.body) }
check_branch(node.else_branch)
end
def check_if_node(node)
return if node.modifier_form? || node.ternary?