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 "blah\nbloop\n"
description " blah\n bloop\n".squish
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?, "(send nil? :description \#{DESCRIPTION_STRING})\n" |
#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?, "(send (lvar _) {:description= :description} \#{DESCRIPTION_STRING})\n" |
#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 |