lib/rubocop/cop/lint/boolean_symbol.rb in rubocop-0.80.1 vs lib/rubocop/cop/lint/boolean_symbol.rb in rubocop-0.81.0
- old
+ new
@@ -30,9 +30,21 @@
def on_sym(node)
return unless boolean_symbol?(node)
add_offense(node, message: format(MSG, boolean: node.value))
end
+
+ def autocorrect(node)
+ lambda do |corrector|
+ boolean_literal = node.source.delete(':')
+ parent = node.parent
+ if parent&.pair_type?
+ corrector.remove(parent.loc.operator)
+ boolean_literal = "#{node.source} =>"
+ end
+ corrector.replace(node.loc.expression, boolean_literal)
+ end
+ end
end
end
end
end