Class: RuboCop::Cop::Grape::PresentWith
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Grape::PresentWith
- Extended by:
- AutoCorrector
- Includes:
- EndpointHelper
- Defined in:
- lib/rubocop/cop/grape/present_with.rb
Overview
Constant Summary collapse
- MSG_TEMPLATE =
'Maybe you mistyped "`%<current>s`", it should be "`%<correct>s`"'
Instance Method Summary collapse
Instance Method Details
#message(key, val) ⇒ Object
43 44 45 |
# File 'lib/rubocop/cop/grape/present_with.rb', line 43 def (key, val) format(MSG_TEMPLATE, current: "#{key}: #{val}", correct: ":#{key}, #{val}") end |
#on_send(present_node) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/grape/present_with.rb', line 32 def on_send(present_node) one_hash_arg_with_key_name_with?(present_node) do |key, val| kwarg = present_node.children.last add_offense(kwarg.children.first, message: (key, val)) do |corrector| corrector.remove(kwarg.children.first) corrector.insert_before(kwarg, ":#{key}, #{val}") end end end |