Class: RuboCop::Cop::Operandi::NoHashArgument
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Operandi::NoHashArgument
- Defined in:
- lib/operandi/rubocop/cop/operandi/no_hash_argument.rb
Overview
Detects when .run or .run! is called with a hash argument instead of keyword arguments.
Since Operandi services now only accept keyword arguments, passing a hash variable
or hash expression will cause an error. Use keyword splatting (**) to convert
hash arguments to keyword arguments.
Constant Summary collapse
- MSG =
"Use keyword arguments or `**` splat instead of hash argument for `.%<method>s`."- RESTRICT_ON_SEND =
[:run, :run!].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/operandi/rubocop/cop/operandi/no_hash_argument.rb', line 47 def on_send(node) return unless RESTRICT_ON_SEND.include?(node.method_name) return unless service_class?(node.receiver) return if node.arguments.empty? return if valid_arguments?(node.arguments) add_offense(node, message: format(MSG, method: node.method_name), severity: :fatal) end |