Class: RuboCop::Cop::Grape::RouteParamType

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

Overview

Checks whether type is specified at points where ‘Grape::API#route_param` is called.

Examples:


# bad
route_param :id

# good
route_param :id, type: Integer
route_param :filename, type: String
route_param :status, type: String, desc: 'Resource Status'

Constant Summary collapse

MSG =
'Define Parameter Type'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/rubocop/cop/grape/route_param_type.rb', line 29

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

  options = node.children.last.children
  return if options.any? { |clild_node| include_key_type?(clild_node) }

  add_offense(node)
end