Class: RuboCop::Cop::Grape::RouteParamGrouping

Inherits:
Base
  • Object
show all
Includes:
EndpointHelper
Defined in:
lib/rubocop/cop/grape/route_param_grouping.rb

Overview

Examples:


# bad
get ':id' do
end

# good
route_param :id, type: Integer do
  get do
  end
end

Constant Summary collapse

MSG =
'Use route_param for route parameter'

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/rubocop/cop/grape/route_param_grouping.rb', line 24

def on_block(node)
  return unless (method_send_node = http_method_node?(node))
  return unless (first_argument_node = method_send_node.arguments.first)
  return unless first_argument_node.value.match?(/:\w/)

  add_offense(first_argument_node)
end