Class: RuboCop::Cop::GraphQL::ObjectDescription
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::GraphQL::ObjectDescription
- Includes:
- GraphQL::DescriptionMethod, GraphQL::NodePattern
- Defined in:
- lib/rubocop/cop/graphql/object_description.rb
Overview
This cop checks if a type (object, input, interface, scalar, union,
mutation, subscription, and resolver) has a description.
Constant Summary collapse
- MSG =
"Missing type description"
Constants included from GraphQL::DescriptionMethod
GraphQL::DescriptionMethod::DESCRIPTION_STRING
Instance Method Summary collapse
Methods included from GraphQL::DescriptionMethod
#description_method_call?, #description_with_block_arg?, #find_description_method
Methods included from GraphQL::NodePattern
#argument?, #field?, #field_definition?, #field_definition_with_body?
Instance Method Details
#interface?(node) ⇒ Object
30 31 32 |
# File 'lib/rubocop/cop/graphql/object_description.rb', line 30 def_node_matcher :interface?, <<~PATTERN (send nil? :include (const ...)) PATTERN |
#on_class(node) ⇒ Object
34 35 36 37 38 |
# File 'lib/rubocop/cop/graphql/object_description.rb', line 34 def on_class(node) return if child_nodes(node).find { |child_node| has_description?(child_node) } add_offense(node.identifier) end |
#on_module(node) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/rubocop/cop/graphql/object_description.rb', line 40 def on_module(node) return if child_nodes(node).none? { |child_node| interface?(child_node) } if child_nodes(node).none? { |child_node| has_description?(child_node) } add_offense(node.identifier) end end |