Class: RuboCop::Cop::GraphQL::LegacyDsl

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/graphql/legacy_dsl.rb

Constant Summary collapse

MSG =
"Avoid using legacy based type-based definitions. " \
"Use class-based definitions instead."
RESTRICT_ON_SEND =
%i[define].freeze

Instance Method Summary collapse

Instance Method Details

#legacy_dsl?(node) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/rubocop/cop/graphql/legacy_dsl.rb', line 24

def_node_matcher :legacy_dsl?, <<~PATTERN
  (block
    (send
      (const
        (const nil? :GraphQL) _) :define)
    ...
  )
PATTERN

#on_send(node) ⇒ Object



37
38
39
40
41
# File 'lib/rubocop/cop/graphql/legacy_dsl.rb', line 37

def on_send(node)
  return unless node.parent.block_type?

  add_offense(node.parent) if legacy_dsl?(node.parent)
end