Class: RuboCop::Cop::Sidekiq::JobLocation
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sidekiq::JobLocation
- Includes:
- Helpers
- Defined in:
- lib/rubocop/cop/sidekiq/job_location.rb
Overview
This cop checks that Sidekiq job classes with “Job” suffix are placed in the ‘app/jobs` directory instead of `app/workers` directory. This follows the modern Sidekiq convention where jobs should be organized in the appropriate directory structure.
Constant Summary collapse
- MSG =
'Job class with `Job` suffix should be placed in `app/jobs` directory instead of `app/workers`.'
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_class(node) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubocop/cop/sidekiq/job_location.rb', line 36 def on_class(node) return unless sidekiq_worker?(node) class_name = extract_class_name(node) return unless class_name return unless class_name.end_with?('Job') file_path = processed_source.buffer.name return unless file_path.include?('app/workers/') add_offense(node.children.first, message: MSG) end |