Class: RuboCop::Cop::Discourse::NoTimeNewWithoutArgs
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Discourse::NoTimeNewWithoutArgs
- Defined in:
- lib/rubocop/cop/discourse/no_time_new_without_args.rb
Overview
Use ‘Time.zone.now` instead of `Time.new` without arguments.
Constant Summary collapse
- MSG =
"Use `Time.zone.now` instead of `Time.new` without arguments."
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
27 28 29 30 31 |
# 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) ⇒ Object
21 22 23 24 25 |
# 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 |