Class: RuboCop::Cop::Captive::Translation::RailsI18nPresence

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/captive/translation/rails_i18n_presence.rb

Overview

Ensure to use the gem rails-i18n in order to have translation

Examples:

# bad
gem 'rails'

# good
gem 'rails'
gem 'rails-i18n'

Constant Summary collapse

MSG =
"The gem `rails-i18n` should be added to the Gemfile "\
"if `rails` is present in Gemfile"

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/rubocop/cop/captive/translation/rails_i18n_presence.rb', line 22

def on_send(node)
  return unless node.command?(:gem)

  gem_name = node.arguments[0]&.value
  return unless gem_name == "rails"

  add_offense(node, message: MSG) unless rails_i18n_present?
end