lib/rubocop/ast_node.rb in rubocop-0.41.2 vs lib/rubocop/ast_node.rb in rubocop-0.42.0

- old
+ new

@@ -111,11 +111,12 @@ def updated(type = nil, children = nil, properties = {}) properties[:location] ||= @location Node.new(type || @type, children || @children, properties) end - # Returns the index of the receiver node in its siblings. + # Returns the index of the receiver node in its siblings. (Sibling index + # uses zero based numbering.) # # @return [Integer] the index of the receiver node in its siblings def sibling_index parent.children.index { |sibling| sibling.equal?(self) } end @@ -562,15 +563,15 @@ end def case_if_value_used? # (case <condition> <when...>) # (if <condition> <truebranch> <falsebranch>) - sibling_index == 0 ? true : parent.value_used? + sibling_index.zero? ? true : parent.value_used? end def while_until_value_used? # (while <condition> <body>) -> always evaluates to `nil` - sibling_index == 0 + sibling_index.zero? end def parent_module_name_part(node) case node.type when :class, :module, :casgn