Class: RuboCop::Cop::Operandi::ArgumentTypeRequired
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Operandi::ArgumentTypeRequired
- Defined in:
- lib/operandi/rubocop/cop/operandi/argument_type_required.rb
Overview
Ensures that all arg declarations in Operandi include a type: option.
Constant Summary collapse
- MSG =
"Argument `%<name>s` must have a `type:` option."- RESTRICT_ON_SEND =
[:arg].freeze
Instance Method Summary collapse
Instance Method Details
#arg_call?(node) ⇒ Object
25 26 27 |
# File 'lib/operandi/rubocop/cop/operandi/argument_type_required.rb', line 25 def_node_matcher :arg_call?, <<~PATTERN (send nil? :arg (sym $_) ...) PATTERN |
#on_send(node) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/operandi/rubocop/cop/operandi/argument_type_required.rb', line 29 def on_send(node) arg_call?(node) do |name| return if has_type_option?(node) add_offense(node, message: format(MSG, name: name)) end end |