-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tech 4747 update contextual logger to normalize context keys to symbols #36
Tech 4747 update contextual logger to normalize context keys to symbols #36
Conversation
end | ||
|
||
def deep_key_has_string?(hash) | ||
hash.keys.any? { |key| key.is_a? String } || hash.any? { |key, value| deep_key_has_string?(value) if value.is_a? Hash } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yinonrousso Our Ruby coding standards say to use parentheses around arguments unless it's a Domain Specific Language.
Also, we only use trailing if
/unless
if it's a rare footnote that normally executes the preceding code.
And the code is jammed up on one line. Here it is spread out a bit:
hash.keys.any? { |key| key.is_a?(String) } ||
hash.any? { |key, value| (value.is_a?(Hash) && deep_key_has_string?(value) }
That's the same as:
hash.any? { |key, value| key.is_a?(String) } ||
hash.any? { |key, value| (value.is_a?(Hash) && deep_key_has_string?(value) }
There's obviously no need to walk the hash twice!
hash.any? do |key, value|
key.is_a?(String) } ||
(value.is_a?(Hash) && deep_key_has_string?(value))
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'll make the appropriate changes 👍
…alize_context_keys_to_symbols
Jira Ticket
Description
Update contextual logger to normalize keys to symbols and warn on string keys
Gotchas
None
For the Code Reviewer: