Welcome to mirror list, hosted at ThFree Co, Russian Federation.

change_timzone.rb « gitlab « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c30a057d51c8f95735bd1d49475278fd9fd892b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module RuboCop
  module Cop
    module Gitlab
      class ChangeTimezone < RuboCop::Cop::Cop
        MSG = "Do not change timezone in the runtime (application or rspec), " \
          "it could result in silently modifying other behavior."

        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