2020-04-24 11:09:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module RuboCop
|
|
|
|
module Cop
|
|
|
|
module Gitlab
|
2022-09-14 11:12:56 -04:00
|
|
|
class ChangeTimezone < RuboCop::Cop::Base
|
2020-04-24 11:09:37 -04:00
|
|
|
MSG = "Do not change timezone in the runtime (application or rspec), " \
|
2021-03-25 23:09:21 -04:00
|
|
|
"it could result in silently modifying other behavior."
|
2020-04-24 11:09:37 -04:00
|
|
|
|
|
|
|
def_node_matcher :changing_timezone?, <<~PATTERN
|
|
|
|
(send (const nil? :Time) :zone= ...)
|
|
|
|
PATTERN
|
|
|
|
|
|
|
|
def on_send(node)
|
|
|
|
changing_timezone?(node) { add_offense(node) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|