Class: RuboCop::Cop::Airbnb::FactoryClassUseString

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/airbnb/factory_class_use_string.rb

Overview

Cop to tell developers to use :class => “MyClass” instead of :class => MyClass, because the latter slows down reloading zeus.

Constant Summary collapse

MSG =
'Instead of :class => MyClass, use :class => "MyClass". ' \
"This enables faster spec startup time and faster Zeus reload time.".freeze
RESTRICT_ON_SEND =
%i(factory).freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/rubocop/cop/airbnb/factory_class_use_string.rb', line 11

def on_send(node)
  return if node.receiver

  class_pair = class_node(node)

  if class_pair && !string_class_name?(class_pair)
    add_offense(class_pair)
  end
end