class RuboCop::Cop::Lint::RandOne
Checks for ‘rand(1)` calls. Such calls always return `0`.
@example
# bad rand 1 Kernel.rand(-1) rand 1.0 rand(-1.0) # good 0 # just use 0 instead
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
Source
# File lib/rubocop/cop/lint/rand_one.rb, line 28 def on_send(node) return unless rand_one?(node) add_offense(node) end
Private Instance Methods
Source
# File lib/rubocop/cop/lint/rand_one.rb, line 36 def message(node) format(MSG, method: node.source) end