Sha256: f366ecede795fb901c1e9a917bf364a0f5d3eb0e6983ddfa537c302d236bbd59
Contents?: true
Size: 708 Bytes
Versions: 5
Compression:
Stored size: 708 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop makes sure that certain operator methods have their sole # parameter named *other*. class OpMethod < Cop MSG = 'When defining the %s operator, name its argument *other*.' BLACKLISTED = [:+@, :-@, :[], :[]=, :<<] TARGET_ARGS = s(:args, s(:arg, :other)) def on_def(node) name, args, _body = *node if name !~ /\A\w/ && !BLACKLISTED.include?(name) && args.children.size == 1 && args != TARGET_ARGS convention(args.children[0], :expression, sprintf(MSG, name)) end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems