diff options
Diffstat (limited to 'rubocop/cop/sidekiq_redis_call.rb')
-rw-r--r-- | rubocop/cop/sidekiq_redis_call.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/rubocop/cop/sidekiq_redis_call.rb b/rubocop/cop/sidekiq_redis_call.rb new file mode 100644 index 00000000000..e4ae430f7c7 --- /dev/null +++ b/rubocop/cop/sidekiq_redis_call.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + # Cop that prevents manually setting a queue in Sidekiq workers. + class SidekiqRedisCall < RuboCop::Cop::Base + MSG = 'Refrain from directly using Sidekiq.redis unless for migration. For admin operations, use Sidekiq APIs.' + + def_node_matcher :using_sidekiq_redis?, <<~PATTERN + (send (const nil? :Sidekiq) :redis) + PATTERN + + def on_send(node) + add_offense(node, message: MSG) if using_sidekiq_redis?(node) + end + end + end +end |