Class: RuboCop::Cop::GraphQL::Heredoc
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::GraphQL::Heredoc
- Defined in:
- lib/rubocop/cop/graphql/heredoc.rb
Overview
Public: Cop for enforcing non-interpolated GRAPHQL heredocs.
Instance Method Summary collapse
- #autocorrect(node) ⇒ Object
- #check_str(node) ⇒ Object
- #on_dstr(node) ⇒ Object
- #on_str(node) ⇒ Object
Instance Method Details
#autocorrect(node) ⇒ Object
24 25 26 27 28 |
# File 'lib/rubocop/cop/graphql/heredoc.rb', line 24 def autocorrect(node) ->(corrector) do corrector.replace(node.location.expression, "<<-'GRAPHQL'") end end |
#check_str(node) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rubocop/cop/graphql/heredoc.rb', line 17 def check_str(node) return unless node.location.is_a?(Parser::Source::Map::Heredoc) return unless node.location.expression.source == "<<-GRAPHQL" add_offense(node, :expression, "GraphQL heredocs should be quoted. <<-'GRAPHQL'") end |
#on_dstr(node) ⇒ Object
9 10 11 |
# File 'lib/rubocop/cop/graphql/heredoc.rb', line 9 def on_dstr(node) check_str(node) end |
#on_str(node) ⇒ Object
13 14 15 |
# File 'lib/rubocop/cop/graphql/heredoc.rb', line 13 def on_str(node) check_str(node) end |