lib/rubocop/cop/style/align_hash.rb in rubocop-0.34.2 vs lib/rubocop/cop/style/align_hash.rb in rubocop-0.35.0
- old
+ new
@@ -154,11 +154,11 @@
end
def on_hash(node)
return if ignored_node?(node)
return if node.children.empty?
- return unless multiline?(node)
+ return unless node.multiline?
@alignment_for_hash_rockets ||=
new_alignment('EnforcedHashRocketStyle')
@alignment_for_colons ||= new_alignment('EnforcedColonStyle')
@@ -197,20 +197,9 @@
node.respond_to?(:type) && node.type == :hash
end
def explicit_hash?(node)
node.loc.begin
- end
-
- # Returns true if the hash spans multiple lines
- def multiline?(node)
- return false unless node.loc.expression.source.include?("\n")
-
- return false if node.children[1..-1].all? do |child|
- !begins_its_line?(child.loc.expression)
- end
-
- true
end
def alignment_for(pair)
if pair.loc.operator.is?('=>')
@alignment_for_hash_rockets