Class: RuboCop::Cop::Rails::ReflectionClassName
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::ReflectionClassName
- Defined in:
- lib/rubocop/cop/rails/reflection_class_name.rb
Overview
Checks if the value of the option `class_name`, in the definition of a reflection is a string.
Constant Summary collapse
- MSG =
'Use a string value for `class_name`.'- RESTRICT_ON_SEND =
%i[has_many has_one belongs_to].freeze
- ALLOWED_REFLECTION_CLASS_TYPES =
%i[dstr str sym].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/rails/reflection_class_name.rb', line 35 def on_send(node) association_with_reflection(node) do |reflection_class_name| return if reflection_class_name.value.send_type? && reflection_class_name.value.receiver.nil? return if reflection_class_name.value.lvar_type? && str_assigned?(reflection_class_name) add_offense(reflection_class_name.loc.expression) end end |