blob: deed68da0b33e912009be0c094565780a3fb841c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# frozen_string_literal: true
module RuboCop
module Cop
module Graphql
class IDType < RuboCop::Cop::Base
MSG = 'Do not use GraphQL::Types::ID, use a specific GlobalIDType instead'
ALLOWLISTED_ARGUMENTS = %i[
iid full_path project_path group_path target_project_path namespace_path
context_namespace_path
].freeze
def_node_search :graphql_id_type?, <<~PATTERN
(send nil? :argument (_ #does_not_match?) (const (const (const nil? :GraphQL) :Types) :ID) ...)
PATTERN
def on_send(node)
return unless graphql_id_type?(node)
add_offense(node)
end
private
def does_not_match?(arg)
!ALLOWLISTED_ARGUMENTS.include?(arg) # rubocop:disable Rails/NegateInclude
end
end
end
end
end
|