class RuboCop::Cop::Discourse::NoTimeNewWithoutArgs
Use `Time.zone.now` instead of `Time.new` without arguments.
@example
# bad now = Time.new # good now = Time.zone.now
Constants
- MSG
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/discourse/no_time_new_without_args.rb, line 27 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.expression, "Time.zone.now") end end
on_send(node)
click to toggle source
# File lib/rubocop/cop/discourse/no_time_new_without_args.rb, line 21 def on_send(node) return unless time_new_without_args?(node) add_offense(node, message: MSG) end