Module: RuboCop::GraphQL::DescriptionMethod
- Extended by:
- NodePattern::Macros
- Included in:
- Cop::GraphQL::ObjectDescription, Argument::Block, Field::Block
- Defined in:
- lib/rubocop/graphql/description_method.rb
Overview
Matches a variety of description formats commonly seen in Rails applications
description 'blah'
description "blah"
description <<~EOT
blah
bloop
EOT
description <<-EOT.squish
blah
bloop
EOT
Constant Summary collapse
- DESCRIPTION_STRING =
"{str|dstr|const|send}"
Instance Method Summary collapse
- #description_method_call?(node) ⇒ Object
- #description_with_block_arg?(node) ⇒ Object
- #find_description_method(nodes) ⇒ Object
Instance Method Details
#description_method_call?(node) ⇒ Object
26 27 28 |
# File 'lib/rubocop/graphql/description_method.rb', line 26 def_node_matcher :description_method_call?, <<~PATTERN (send nil? :description #{DESCRIPTION_STRING}) PATTERN |
#description_with_block_arg?(node) ⇒ Object
31 32 33 |
# File 'lib/rubocop/graphql/description_method.rb', line 31 def_node_matcher :description_with_block_arg?, <<~PATTERN (send (lvar _) {:description= :description} #{DESCRIPTION_STRING}) PATTERN |
#find_description_method(nodes) ⇒ Object
35 36 37 |
# File 'lib/rubocop/graphql/description_method.rb', line 35 def find_description_method(nodes) nodes.find { |kwarg| description_method_call?(kwarg) || description_with_block_arg?(kwarg) } end |