Sha256: 02778045d2e2c4d5531bcdb12c4953c779d491b5227e03e0351a45ce42e864b5
Contents?: true
Size: 718 Bytes
Versions: 7
Compression:
Stored size: 718 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)), s(:args, s(:arg, :_other))] def on_def(node) name, args, _body = *node return unless name !~ /\A\w/ && !BLACKLISTED.include?(name) && args.children.size == 1 && !TARGET_ARGS.include?(args) add_offense(args.children[0], :expression, format(MSG, name)) end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems