debian-mirror-gitlab/rubocop/cop/gitlab/union.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
597 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# 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.
2022-10-11 01:57:18 +05:30
class Union < RuboCop::Cop::Base
2018-12-05 23:21:45 +05:30
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)
2022-10-11 01:57:18 +05:30
add_offense(node)
2018-12-05 23:21:45 +05:30
end
end
end
end
end