Sha256: 0cf46a2271fdd6988b943284473a6200e37731f874cd1f18ee7a668165945a22
Contents?: true
Size: 709 Bytes
Versions: 2
Compression:
Stored size: 709 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 add_offense(args.children[0], :expression, format(MSG, name)) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/style/op_method.rb |
rubocop-0.19.0 | lib/rubocop/cop/style/op_method.rb |