Class: RuboCop::Cop::Mirego::ReceiveCounts
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Mirego::ReceiveCounts
- Defined in:
- lib/rubocop/cop/mirego/receive_counts.rb
Constant Summary collapse
- MESSAGE =
'Always specify a receive count with `receive`'.freeze
- RECEIVE_COUNTS_METHODS =
i(once twice exactly at_least at_most).freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubocop/cop/mirego/receive_counts.rb', line 8 def on_send(node) receiver, method_name, *args = *node return nil unless method_name == :to return nil if receiver.nil? || receiver.to_a[1] != :expect methods_name = recursive_methods_name(nodes: args) return nil unless methods_name.include? :receive return nil unless (methods_name & RECEIVE_COUNTS_METHODS).empty? add_offense(node, :expression, MESSAGE) end |