gitlab-org--gitlab-foss/rubocop/cop/gitlab/union.rb
Peter Leitzen e101a26444 Utilize RuboCop's Include/Exclude config
Stop checking the file location programmatically.
2019-08-26 12:24:25 +00:00

23 lines
619 B
Ruby

# frozen_string_literal: true
module RuboCop
module Cop
module Gitlab
# Cop that disallows the use of `Gitlab::SQL::Union`, in favour of using
# the `FromUnion` module.
class Union < RuboCop::Cop::Cop
MSG = 'Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly'
def_node_matcher :raw_union?, <<~PATTERN
(send (const (const (const nil? :Gitlab) :SQL) :Union) :new ...)
PATTERN
def on_send(node)
return unless raw_union?(node)
add_offense(node, location: :expression)
end
end
end
end
end