lib/rubocop/cop/style/align_hash.rb in rubocop-0.18.0 vs lib/rubocop/cop/style/align_hash.rb in rubocop-0.18.1

- old
+ new

@@ -140,14 +140,15 @@ first_value.loc.column - current_value.loc.column end end MSG = 'Align the elements of a hash literal if they span more than ' \ - 'one line.' + 'one line.' def on_hash(node) return if node.children.empty? + return unless multiline?(node) @alignment_for_hash_rockets ||= new_alignment('EnforcedHashRocketStyle') @alignment_for_colons ||= new_alignment('EnforcedColonStyle') @@ -168,9 +169,13 @@ add_offence(current, :expression) unless good_alignment? end end private + + def multiline?(node) + node.loc.expression.source.include?("\n") + end def alignment_for(pair) if pair.loc.operator.is?('=>') @alignment_for_hash_rockets else