class RubbyCop::Cop::Style::OpMethod
This cop makes sure that certain binary operator methods have their sole parameter named `other`.
@example
# bad def +(amount); end # good def +(other); end
Constants
- BLACKLISTED
- MSG
- OP_LIKE_METHODS
Public Instance Methods
on_def(node)
click to toggle source
# File lib/rubbycop/cop/style/op_method.rb, line 27 def on_def(node) op_method_candidate?(node) do |name, arg| return unless op_method?(name) add_offense(arg, :expression, format(MSG, name)) end end
op_method?(name)
click to toggle source
# File lib/rubbycop/cop/style/op_method.rb, line 34 def op_method?(name) return false if BLACKLISTED.include?(name) name !~ /\A\w/ || OP_LIKE_METHODS.include?(name) end