Class: RuboCop::Cop::Carwow::JobsQueueNameStyle
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Carwow::JobsQueueNameStyle
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/carwow/jobs_queue_name_style.rb
Overview
Constant Summary collapse
- MSG =
'Prefer `queue_as` with symbol instead of String'- MSG_STRING =
'Prefer `queue_as` with String instead of Symbol'- RESTRICT_ON_SEND =
optimization: don’t call ‘on_send` unless the method name is in this list
i[queue_as].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubocop/cop/carwow/jobs_queue_name_style.rb', line 44 def on_send(node) _, _queue_as, queue_name = *node return if prefer_symbol? && queue_name.sym_type? return if prefer_string? && queue_name.str_type? add_offense(queue_name, message: (prefer_symbol? ? MSG : MSG_STRING)) do |corrector| content, _other = *queue_name fix = prefer_symbol? ? ":#{content}" : content.to_s.inspect corrector.replace(queue_name, fix) end end |