lib/rubocop/cop/rails/time_zone.rb in rubocop-rails-2.1.0 vs lib/rubocop/cop/rails/time_zone.rb in rubocop-rails-2.2.0
- old
+ new
@@ -53,26 +53,24 @@
'Use one of %<prefer>s instead.'
MSG_LOCALTIME = 'Do not use `Time.localtime` without ' \
'offset or zone.'
- TIMECLASSES = %i[Time DateTime].freeze
-
GOOD_METHODS = %i[zone zone_default find_zone find_zone!].freeze
DANGEROUS_METHODS = %i[now local new parse at current].freeze
ACCEPTED_METHODS = %i[in_time_zone utc getlocal xmlschema iso8601
jisx0301 rfc3339 httpdate to_i to_f].freeze
def on_const(node)
mod, klass = *node
# we should only check core classes
- # (`DateTime`, `Time`, `::DateTime` or `::Time`)
+ # (`Time` or `::Time`)
return unless (mod.nil? || mod.cbase_type?) && method_send?(node)
- check_time_node(klass, node.parent) if TIMECLASSES.include?(klass)
+ check_time_node(klass, node.parent) if klass == :Time
end
def autocorrect(node)
lambda do |corrector|
# add `.zone`: `Time.at` => `Time.zone.at`
@@ -151,10 +149,10 @@
def method_from_time_class?(node)
receiver, method_name, *_args = *node
if (receiver.is_a? RuboCop::AST::Node) && !receiver.cbase_type?
method_from_time_class?(receiver)
else
- TIMECLASSES.include?(method_name)
+ method_name == :Time
end
end
# checks that parent node of send_type
# and receiver is the given node