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