class RuboCop::Cop::Lint::StringToInt
This cop checks for possible calls to String#to_i instead of Kernel#.Integer.
Constants
- MSG
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/lint/string_to_int.rb, line 9 def on_send(node) receiver, method_name, * = *node return unless method_name == :to_i return unless check_receiver(receiver) add_offense(node, :expression) end
Private Instance Methods
check_receiver(receiver)
click to toggle source
# File lib/rubocop/cop/lint/string_to_int.rb, line 20 def check_receiver(receiver) return false unless receiver receiver.str_type? || receiver.lvar_type? end