summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-29 09:08:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-29 09:08:03 +0000
commitad2789aeba21edaadcbdc06523462e6fd87d4ba1 (patch)
tree319403c595130a4f78fae367c7cedc88466dd9db /rubocop
parent2add640cfc67c927eb41cf542ef39ecda4c456c1 (diff)
downloadgitlab-ce-ad2789aeba21edaadcbdc06523462e6fd87d4ba1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/migration/sidekiq_queue_migrate.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/rubocop/cop/migration/sidekiq_queue_migrate.rb b/rubocop/cop/migration/sidekiq_queue_migrate.rb
new file mode 100644
index 00000000000..134bda590da
--- /dev/null
+++ b/rubocop/cop/migration/sidekiq_queue_migrate.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require_relative '../../migration_helpers'
+
+module RuboCop
+ module Cop
+ module Migration
+ # Cop that checks if sidekiq_queue_migrate is used in a regular
+ # (not post-deployment) migration.
+ class SidekiqQueueMigrate < RuboCop::Cop::Cop
+ include MigrationHelpers
+
+ MSG = '`sidekiq_queue_migrate` must only be used in post-deployment migrations'
+
+ def on_def(node)
+ return unless in_migration?(node) && !in_post_deployment_migration?(node)
+
+ node.each_descendant(:send) do |send_node|
+ send_method = send_node.children[1]
+
+ if send_method == :sidekiq_queue_migrate
+ add_offense(send_node, location: :selector)
+ end
+ end
+ end
+ end
+ end
+ end
+end