Sha256: a74ac3feb20705512e34bdaeb0b714139aa9f0f77ec7785613e8fd619d8e4818
Contents?: true
Size: 725 Bytes
Versions: 4
Compression:
Stored size: 725 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_offence(:convention, args.children[0].loc.expression, sprintf(MSG, name)) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems