Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bulk_insert.rb « gitlab « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f88dcde2dc2429348eaf4bbd8c073fb142aed446 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module RuboCop
  module Cop
    module Gitlab
      # Cop that disallows the use of `legacy_bulk_insert`, in favour of using
      # the `BulkInsertSafe` module.
      class BulkInsert < RuboCop::Cop::Base
        MSG = 'Use the `BulkInsertSafe` concern, instead of using `LegacyBulkInsert.bulk_insert`. See https://docs.gitlab.com/ee/development/insert_into_tables_in_batches.html'

        def_node_matcher :raw_union?, <<~PATTERN
          (send _ :legacy_bulk_insert ...)
        PATTERN

        def on_send(node)
          return unless raw_union?(node)

          add_offense(node)
        end
      end
    end
  end
end