This cop checks for places where Fixnum#even? or Fixnum#odd? should have been used.
@example
# bad if x % 2 == 0 # good if x.even?
# File lib/rubocop/cop/style/even_odd.rb, line 23 def on_send(node) receiver, method, args = *node return unless [:==, :!=].include?(method) return unless div_by_2?(receiver) if args == ZERO add_offense(node, :expression, method == :== ? MSG_EVEN : MSG_ODD) elsif args == ONE add_offense(node, :expression, method == :== ? MSG_ODD : MSG_EVEN) end end
Generated with the Darkfish Rdoc Generator 2.