class RuboCop::Cop::InternalAffairs::NodeTypePredicate
Checks that node types are checked using the predicate helpers.
@example
# bad node.type == :send # good node.send_type?
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/internal_affairs/node_type_predicate.rb, line 27 def on_send(node) node_type_check(node) do |receiver, node_type| return unless Parser::Meta::NODE_TYPES.include?(node_type) message = format(MSG, type: node_type) add_offense(node, message: message) do |corrector| range = node.loc.expression.with(begin_pos: receiver.loc.expression.end_pos + 1) corrector.replace(range, "#{node_type}_type?") end end end