2020-06-05 11:08:23 -04:00
# frozen_string_literal: true
module RuboCop
module Cop
module Gitlab
2021-11-15 10:10:57 -05:00
# Cop that disallows the use of `legacy_bulk_insert`, in favour of using
2020-06-05 11:08:23 -04:00
# the `BulkInsertSafe` module.
2022-09-14 11:12:56 -04:00
class BulkInsert < RuboCop :: Cop :: Base
2021-11-15 10:10:57 -05:00
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-05 11:08:23 -04:00
def_node_matcher :raw_union? , << ~ PATTERN
2021-11-15 10:10:57 -05:00
( send _ :legacy_bulk_insert ... )
2020-06-05 11:08:23 -04:00
PATTERN
def on_send ( node )
return unless raw_union? ( node )
2022-09-14 11:12:56 -04:00
add_offense ( node )
2020-06-05 11:08:23 -04:00
end
end
end
end
end