Class: RuboCop::Cop::GraphQL::Heredoc
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::RuboCop::Cop
|
|
Instance Chain:
self,
::RuboCop::Cop
|
|
Inherits: |
RuboCop::Cop
|
Defined in: | lib/rubocop/cop/graphql/heredoc.rb |
Overview
Public: ::RuboCop::Cop
for enforcing non-interpolated GRAPHQL heredocs.
Instance Method Summary
Instance Method Details
#autocorrect(node)
[ GitHub ]# File 'lib/rubocop/cop/graphql/heredoc.rb', line 29
def autocorrect(node) ->(corrector) do corrector.replace(node.location.expression, "<<-'GRAPHQL'") end end
#check_str(node)
[ GitHub ]# 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/ node.each_child_node(:begin) do |begin_node| add_offense(begin_node, location: :expression, message: "Do not interpolate variables into GraphQL queries, " \ "used variables instead.") end add_offense(node, location: :expression, message: "GraphQL heredocs should be quoted. <<-'GRAPHQL'") end
#on_dstr(node)
[ GitHub ]# File 'lib/rubocop/cop/graphql/heredoc.rb', line 9
def on_dstr(node) check_str(node) end
#on_str(node)
[ GitHub ]# File 'lib/rubocop/cop/graphql/heredoc.rb', line 13
def on_str(node) check_str(node) end