debian-mirror-gitlab/rubocop/cop/gitlab/bulk_insert.rb

24 lines
660 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module RuboCop
module Cop
module Gitlab
2021-12-11 22:18:48 +05:30
# Cop that disallows the use of `legacy_bulk_insert`, in favour of using
2020-06-23 00:09:42 +05:30
# the `BulkInsertSafe` module.
2022-10-11 01:57:18 +05:30
class BulkInsert < RuboCop::Cop::Base
2021-12-11 22:18:48 +05:30
MSG = 'Use the `BulkInsertSafe` concern, instead of using `LegacyBulkInsert.bulk_insert`. See https://docs.gitlab.com/ee/development/insert_into_tables_in_batches.html'
2020-06-23 00:09:42 +05:30
def_node_matcher :raw_union?, <<~PATTERN
2021-12-11 22:18:48 +05:30
(send _ :legacy_bulk_insert ...)
2020-06-23 00:09:42 +05:30
PATTERN
def on_send(node)
return unless raw_union?(node)
2022-10-11 01:57:18 +05:30
add_offense(node)
2020-06-23 00:09:42 +05:30
end
end
end
end
end