Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop/cop/scalability')
-rw-r--r--rubocop/cop/scalability/bulk_perform_with_context.rb8
-rw-r--r--rubocop/cop/scalability/cron_worker_context.rb2
2 files changed, 8 insertions, 2 deletions
diff --git a/rubocop/cop/scalability/bulk_perform_with_context.rb b/rubocop/cop/scalability/bulk_perform_with_context.rb
index 3c5d7f39680..b96aa35bfee 100644
--- a/rubocop/cop/scalability/bulk_perform_with_context.rb
+++ b/rubocop/cop/scalability/bulk_perform_with_context.rb
@@ -23,6 +23,8 @@ module RuboCop
Read more about it https://docs.gitlab.com/ee/development/sidekiq_style_guide.html#worker-context
MSG
+ BACKGROUND_MIGRATION_WORKER_NAMES = %w[BackgroundMigrationWorker CiDatabaseWorker].freeze
+
def_node_matcher :schedules_in_batch_without_context?, <<~PATTERN
(send (...) {:bulk_perform_async :bulk_perform_in} _*)
PATTERN
@@ -30,7 +32,7 @@ module RuboCop
def on_send(node)
return if in_migration?(node) || in_spec?(node)
return unless schedules_in_batch_without_context?(node)
- return if name_of_receiver(node) == "BackgroundMigrationWorker"
+ return if scheduled_for_background_migration?(node)
add_offense(node, location: :expression)
end
@@ -40,6 +42,10 @@ module RuboCop
def in_spec?(node)
file_path_for_node(node).end_with?("_spec.rb")
end
+
+ def scheduled_for_background_migration?(node)
+ BACKGROUND_MIGRATION_WORKER_NAMES.include?(name_of_receiver(node))
+ end
end
end
end
diff --git a/rubocop/cop/scalability/cron_worker_context.rb b/rubocop/cop/scalability/cron_worker_context.rb
index 8e754af4dcf..3cc0d42d7bc 100644
--- a/rubocop/cop/scalability/cron_worker_context.rb
+++ b/rubocop/cop/scalability/cron_worker_context.rb
@@ -11,7 +11,7 @@ module RuboCop
If there is no relevant metadata, please disable the cop with a comment
explaining this.
- Read more about it https://docs.gitlab.com/ee/development/sidekiq_style_guide.html#worker-context
+ Read more about it https://docs.gitlab.com/ee/development/sidekiq/logging.html#worker-context
MSG
def_node_matcher :includes_cronjob_queue?, <<~PATTERN