class RuboCop::Cop::InternalAffairs::CreateEmptyFile
Checks for uses of ‘create_file` with empty string second argument.
@example
# bad create_file(path, '') # good create_empty_file(path)
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/internal_affairs/create_empty_file.rb, line 22 def on_send(node) return if node.receiver return unless (argument = node.arguments[1]) return unless argument.str_type? && argument.value.empty? replacement = "create_empty_file(#{node.first_argument.source})" message = format(MSG, replacement: replacement) add_offense(node, message: message) do |corrector| corrector.replace(node, replacement) end end