Class: RuboCop::Cop::Sidekiq::ConstArgument
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sidekiq::ConstArgument
- Includes:
- Helpers
- Defined in:
- lib/rubocop/cop/sidekiq/const_argument.rb
Overview
This cop checks for Sidekiq worker perform arguments that look like classes or modules. These cannot be serialized for Redis, and should not be used with Sidekiq.
Constants other than classes/modules are not flagged by this cop.
Constant Summary collapse
- CONSTANT_NAME =
/\A[A-Z0-9_]+\z/.freeze
- MSG =
'Objects are not native JSON types.'- MSG_SELF =
'`self` is not a native JSON type.'
Constants included from Helpers
Instance Method Summary collapse
Methods included from Helpers
#approve_node, #expand_array_node, #expand_hash_array_node, #expand_hash_node, #expand_node, #expand_nodes, #in_sidekiq_worker?, included, #node_approved?, #sidekiq_arguments, #within?
Instance Method Details
#on_send(node) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/rubocop/cop/sidekiq/const_argument.rb', line 43 def on_send(node) sidekiq_arguments(node).each do |arg| next unless const_argument?(arg) next if non_class_constant?(arg) add_offense(arg, message: arg.self_type? ? MSG_SELF : MSG) end end |