Class: RuboCop::Cop::Rails::I18nLocaleTexts
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::I18nLocaleTexts
- Defined in:
- lib/rubocop/cop/rails/i18n_locale_texts.rb
Overview
Enforces use of I18n and locale files instead of locale specific strings.
Constant Summary collapse
- MSG =
'Move locale texts to the locale files in the `config/locales` directory.'- RESTRICT_ON_SEND =
%i[validates redirect_to redirect_back redirect_back_or_to []= mail].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/rubocop/cop/rails/i18n_locale_texts.rb', line 116 def on_send(node) case node.method_name when :validates (node) do |text_node| add_offense(text_node) end return when :redirect_to, :redirect_back, :redirect_back_or_to text_node = redirect_to_flash(node).to_a.last when :[]= text_node = flash_assignment?(node) when :mail text_node = mail_subject(node).to_a.last end add_offense(text_node) if text_node end |