Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ilable in active sessions
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
module RuboCop | ||
module Cop | ||
module Zammad | ||
class TimezoneDefault < Base | ||
def on_str(node) | ||
return if !matching_string?(node) | ||
return if !matching_node?(node) | ||
|
||
add_offense(node.parent, message: <<~TEXT.chomp) | ||
Setting.get('timezone_default_sanitized') is removed. | ||
Please use Setting.get('timezone_default') directly. | ||
TEXT | ||
end | ||
|
||
def matching_string?(node) | ||
node.source == "'timezone_default_sanitized'" | ||
end | ||
|
||
def matching_node?(node) | ||
parent = node.parent | ||
|
||
return false if !parent | ||
|
||
parent.receiver&.const_name == 'Setting' && parent.method_name == :get | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters