summaryrefslogtreecommitdiff
path: root/rubocop/cop/migration
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop/cop/migration')
-rw-r--r--rubocop/cop/migration/schedule_async.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/rubocop/cop/migration/schedule_async.rb b/rubocop/cop/migration/schedule_async.rb
index f31bfa46aa7..4fdedecdf64 100644
--- a/rubocop/cop/migration/schedule_async.rb
+++ b/rubocop/cop/migration/schedule_async.rb
@@ -16,14 +16,23 @@ module RuboCop
MSG
def_node_matcher :calls_background_migration_worker?, <<~PATTERN
- (send (const nil? :BackgroundMigrationWorker) {:perform_async :perform_in :bulk_perform_async :bulk_perform_in} ... )
+ (send (const {cbase nil?} :BackgroundMigrationWorker) #perform_method? ...)
+ PATTERN
+
+ def_node_matcher :calls_ci_database_worker?, <<~PATTERN
+ (send (const {(const {cbase nil?} :BackgroundMigration) nil?} :CiDatabaseWorker) #perform_method? ...)
+ PATTERN
+
+ def_node_matcher :perform_method?, <<~PATTERN
+ {:perform_async :bulk_perform_async :perform_in :bulk_perform_in}
PATTERN
def on_send(node)
return unless in_migration?(node)
return if version(node) < ENFORCED_SINCE
+ return unless calls_background_migration_worker?(node) || calls_ci_database_worker?(node)
- add_offense(node, location: :expression) if calls_background_migration_worker?(node)
+ add_offense(node, location: :expression)
end
end
end