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

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

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



13
14
15
16
17
18
19
20
# File 'lib/rubocop/cop/captive/translation/rails_i18n_presence.rb', line 13

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