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

intersect.rb « gitlab « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4b61073b804250750d0a2546a4541e32d51aec16 (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 `Gitlab::SQL::Intersect`, in favour of using
      # the `FromIntersect` module.
      class Intersect < RuboCop::Cop::Cop
        MSG = 'Use the `FromIntersect` concern, instead of using `Gitlab::SQL::Intersect` directly'

        def_node_matcher :raw_intersect?, <<~PATTERN
          (send (const (const (const nil? :Gitlab) :SQL) :Intersect) :new ...)
        PATTERN

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

          add_offense(node, location: :expression)
        end
      end
    end
  end
end