Class: RuboCop::Cop::Mable::GraphQLHelperSpecs

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/mable/graph_ql_helper_specs.rb

Overview

The graphql path may change avoid hardcoding and use the url helper instead.

Examples:


# bad
post '/graphql'

# good
post graphql_path

Constant Summary collapse

MSG =
'Avoid hardcoding GraphQL URL paths, instead, use the helper method.'
RESTRICT_ON_SEND =
i[post].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rubocop/cop/mable/graph_ql_helper_specs.rb', line 27

def on_send(node)
  return unless post_graphql?(node)

  add_offense(node) do |corrector|
    corrector.replace(node.child_nodes[0], 'graphql_path')
  end
end