Class: RuboCop::Cop::I18n::GetText::DecorateFunctionMessage

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/i18n/gettext/decorate_function_message.rb

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rubocop/cop/i18n/gettext/decorate_function_message.rb', line 25

def autocorrect(node)
  if node.str_type?
    single_string_correct(node)
  elsif interpolation_offense?(node)
    #              interpolation_correct(node)
  end
end

#on_send(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubocop/cop/i18n/gettext/decorate_function_message.rb', line 8

def on_send(node)
  method_name = node.loc.selector.source
  return unless GetText.supported_method?(method_name)

  method_name = node.method_name
  arg_nodes = node.arguments
  if !arg_nodes.empty? && !already_decorated?(node) && (contains_string?(arg_nodes) || string_constant?(arg_nodes))
    message_section = if string_constant?(arg_nodes)
                        arg_nodes[1]
                      else
                        arg_nodes[0]
                      end

    detect_and_report(node, message_section, method_name)
  end
end