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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-06 15:08:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-06 15:08:38 +0300
commit6ab9cdec264a9caf7e4eb5519fcae5ac65a18b15 (patch)
tree28afca02f01c1b9d22a5e4227521a575fae57bea /rubocop
parent497d517e130ac88cbdee69c4c9e88938e164fc52 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/migration/add_concurrent_foreign_key.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/rubocop/cop/migration/add_concurrent_foreign_key.rb b/rubocop/cop/migration/add_concurrent_foreign_key.rb
index 236de6224a4..31cf426b2d4 100644
--- a/rubocop/cop/migration/add_concurrent_foreign_key.rb
+++ b/rubocop/cop/migration/add_concurrent_foreign_key.rb
@@ -11,7 +11,11 @@ module RuboCop
MSG = '`add_foreign_key` requires downtime, use `add_concurrent_foreign_key` instead'.freeze
def_node_matcher :false_node?, <<~PATTERN
- (false)
+ (false)
+ PATTERN
+
+ def_node_matcher :with_lock_retries?, <<~PATTERN
+ (:send nil? :with_lock_retries)
PATTERN
def on_send(node)
@@ -19,9 +23,11 @@ module RuboCop
name = node.children[1]
- if name == :add_foreign_key && !not_valid_fk?(node)
- add_offense(node, location: :selector)
- end
+ return unless name == :add_foreign_key
+ return if in_with_lock_retries?(node)
+ return if not_valid_fk?(node)
+
+ add_offense(node, location: :selector)
end
def method_name(node)
@@ -33,6 +39,12 @@ module RuboCop
pair.children[0].children[0] == :validate && false_node?(pair.children[1])
end
end
+
+ def in_with_lock_retries?(node)
+ node.each_ancestor(:block).any? do |parent|
+ with_lock_retries?(parent.to_a.first)
+ end
+ end
end
end
end