class Rubocop::Cop::Style::CollectionMethods
This cop checks for uses of unidiomatic method names from the Enumerable module.
The current definition of the check is flawed and should be enhanced by check for by blocks & procs as arguments of the methods.
Constants
- MSG
- PREFERRED_METHODS
Public Instance Methods
on_block(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/collection_methods.rb, line 22 def on_block(node) method, _args, _body = *node check_method_node(method) super end
on_send(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/collection_methods.rb, line 30 def on_send(node) _receiver, _method_name, *args = *node if args.size == 1 && args.first.type == :block_pass check_method_node(node) end super end
Private Instance Methods
check_method_node(node)
click to toggle source
# File lib/rubocop/cop/style/collection_methods.rb, line 42 def check_method_node(node) _receiver, method_name, *_args = *node if PREFERRED_METHODS[method_name] add_offence( :convention, node.loc.selector, sprintf(MSG, PREFERRED_METHODS[method_name], method_name) ) end end