Sha256: 40166b2a41f659501f10fb279b0c1836211eb1cff2ebf62e97304530787426d9
Contents?: true
Size: 690 Bytes
Versions: 13
Compression:
Stored size: 690 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class CollectionMethods < Cop PREFERRED_METHODS = { 'collect' => 'map', 'inject' => 'reduce', 'detect' => 'find', 'find_all' => 'select', } def inspect(file, source, tokens, sexp) each(:call, sexp) do |s| s.drop(2).each_slice(2) do |m| method_name = m[1][1] if PREFERRED_METHODS[method_name] add_offence( :convention, m[1][2].lineno, "Prefer #{PREFERRED_METHODS[method_name]} over #{method_name}." ) end end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems