2020-06-05 11:08:23 -04:00
# frozen_string_literal: true
module RuboCop
module Cop
module Gitlab
2021-07-29 11:09:48 -04:00
# Cop that disallows the use of `Gitlab::Database.main.bulk_insert`, in favour of using
2020-06-05 11:08:23 -04:00
# the `BulkInsertSafe` module.
class BulkInsert < RuboCop :: Cop :: Cop
2021-07-29 11:09:48 -04:00
MSG = 'Use the `BulkInsertSafe` concern, instead of using `Gitlab::Database.main.bulk_insert`. See https://docs.gitlab.com/ee/development/insert_into_tables_in_batches.html'
2020-06-05 11:08:23 -04:00
def_node_matcher :raw_union? , << ~ PATTERN
2021-07-29 11:09:48 -04:00
( send ( send ( const ( const _ :Gitlab ) :Database ) :main ) :bulk_insert ... )
2020-06-05 11:08:23 -04:00
PATTERN
def on_send ( node )
return unless raw_union? ( node )
add_offense ( node , location : :expression )
end
end
end
end
end