lib/rubocop/ast/node/if_node.rb in rubocop-ast-1.1.0 vs lib/rubocop/ast/node/if_node.rb in rubocop-ast-1.1.1

- old
+ new

@@ -143,19 +143,22 @@ # Returns an array of all the branches in the conditional statement. # # @return [Array<Node>] an array of branch nodes def branches - branches = [if_branch] - - return branches unless else? - - other_branches = if elsif_conditional? - else_branch.branches - else - [else_branch] - end - branches.concat(other_branches) + if ternary? + [if_branch, else_branch] + elsif !else? + [if_branch] + else + branches = [if_branch] + other_branches = if elsif_conditional? + else_branch.branches + else + [else_branch] + end + branches.concat(other_branches) + end end # @deprecated Use `branches.each` def each_branch(&block) return branches.to_enum(__method__) unless block_given?