lib/rubocop/cop/rails/exit.rb in rubocop-rails-2.8.1 vs lib/rubocop/cop/rails/exit.rb in rubocop-rails-2.9.0

- old
+ new

@@ -21,30 +21,24 @@ # # bad # exit(0) # # # good # raise 'a bad error has happened' - class Exit < Cop + class Exit < Base include ConfigurableEnforcedStyle MSG = 'Do not use `exit` in Rails applications.' - TARGET_METHODS = %i[exit exit!].freeze + RESTRICT_ON_SEND = %i[exit exit!].freeze EXPLICIT_RECEIVERS = %i[Kernel Process].freeze def on_send(node) - add_offense(node, location: :selector) if offending_node?(node) + add_offense(node.loc.selector) if offending_node?(node) end private def offending_node?(node) - right_method_name?(node.method_name) && - right_argument_count?(node.arguments) && - right_receiver?(node.receiver) - end - - def right_method_name?(method_name) - TARGET_METHODS.include?(method_name) + right_argument_count?(node.arguments) && right_receiver?(node.receiver) end # More than 1 argument likely means it is a different # `exit` implementation than the one we are preventing. def right_argument_count?(arg_nodes)