lib/rubocop/cop/style/hash_syntax.rb in rubocop-0.52.0 vs lib/rubocop/cop/style/hash_syntax.rb in rubocop-0.52.1
- old
+ new
@@ -171,14 +171,15 @@
op = pair_node.loc.operator
range = range_between(key.source_range.begin_pos, op.end_pos)
range = range_with_surrounding_space(range: range, side: :right)
- new_key = key.sym_type? ? key.value : key.source
-
space = argument_without_space?(pair_node.parent) ? ' ' : ''
- corrector.replace(range, "#{space}#{new_key}: ")
+ corrector.replace(
+ range,
+ range.source.sub(/^:(.*\S)\s*=>\s*$/, space.to_s + '\1: ')
+ )
end
def argument_without_space?(node)
node.argument? &&
node.loc.expression.begin_pos == node.parent.loc.selector.end_pos