class RuboCop::Cop::Rails::I18nLocaleTexts


end
end
mail(to: user.email)
def welcome(user)
class UserMailer < ApplicationMailer
# subject: “Welcome to My Awesome Site”
# welcome:
# user_mailer:
# en:
# config/locales/en.yml
# good
end
end
mail(to: user.email, subject: “Welcome to My Awesome Site”)
def welcome(user)
class UserMailer < ApplicationMailer
# bad
end
end
redirect_to root_path, notice: t(“.success”)
# …
def create
class PostsController < ApplicationController
# success: “Post created!”
# create:
# posts:
# en:
# config/locales/en.yml
# good
end
end
redirect_to root_path, notice: “Post created!”
# …
def create
class PostsController < ApplicationController
# bad
end
validates :email, presence: true
class User < ApplicationRecord
# blank: “must be present”
# user:
# models:
# errors:
# activerecord:
# en:
# config/locales/en.yml
# good
end
validates :email, presence: { message: “must be present” }
class User < ApplicationRecord
# bad
@example
Enforces use of I18n and locale files instead of locale specific strings.

def on_send(node)

def on_send(node)
  case node.method_name
  when :validates
    validation_message(node) do |text_node|
      add_offense(text_node)
    end
    return
  when :redirect_to, :redirect_back
    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