class RuboCop::Cop::Rails::I18nLocaleAssignment
end
I18n.with_locale(:fr) do
# good
I18n.locale = :fr
# bad
@example
It eliminates the possibility of a ‘locale` sticking around longer than intended.
Using `I18n.with_locale` ensures the code passed in the block is the only place `I18n.locale` is affected.
unexpected behavior at a later time.
The `locale` attribute persists for the rest of the Ruby runtime, potentially causing
Checks for the use of `I18n.locale=` method.
def on_send(node)
def on_send(node) return unless i18n_locale_assignment?(node) add_offense(node) end