lib/rubocop/cop/layout/hash_alignment.rb in rubocop-1.25.0 vs lib/rubocop/cop/layout/hash_alignment.rb in rubocop-1.25.1
- old
+ new
@@ -220,12 +220,17 @@
def autocorrect_incompatible_with_other_cops?(node)
return false unless enforce_first_argument_with_fixed_indentation? &&
node.pairs.any? &&
node.parent&.call_type?
+ left_sibling = argument_before_hash(node)
parent_loc = node.parent.loc
- selector = parent_loc.selector || parent_loc.expression
+ selector = left_sibling || parent_loc.selector || parent_loc.expression
same_line?(selector, node.pairs.first)
+ end
+
+ def argument_before_hash(hash_node)
+ hash_node.left_sibling.respond_to?(:loc) ? hash_node.left_sibling : nil
end
def reset!
self.offenses_by = {}
self.column_deltas = Hash.new { |hash, key| hash[key] = {} }