diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-05 18:08:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-05 18:08:23 +0300 |
commit | 86e1f47cd19e7c164fb0b2c24e28a63ea27ae5ff (patch) | |
tree | 016d11e5f9df14b69e28475641160c8a843cbc34 /rubocop | |
parent | 38b39c50473ba58a80ddad5c22c96ccd5128ddfb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/gitlab/bulk_insert.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rubocop/cop/gitlab/bulk_insert.rb b/rubocop/cop/gitlab/bulk_insert.rb new file mode 100644 index 00000000000..c03ffbe0b2a --- /dev/null +++ b/rubocop/cop/gitlab/bulk_insert.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Gitlab + # Cop that disallows the use of `Gitlab::Database.bulk_insert`, in favour of using + # the `BulkInsertSafe` module. + class BulkInsert < RuboCop::Cop::Cop + MSG = 'Use the `BulkInsertSafe` concern, instead of using `Gitlab::Database.bulk_insert`. See https://docs.gitlab.com/ee/development/insert_into_tables_in_batches.html' + + def_node_matcher :raw_union?, <<~PATTERN + (send (const (const nil? :Gitlab) :Database) :bulk_insert ...) + PATTERN + + def on_send(node) + return unless raw_union?(node) + + add_offense(node, location: :expression) + end + end + end + end +end |