Class: RuboCop::Cop::GitHub::RailsControllerRenderActionSymbol

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/github/rails_controller_render_action_symbol.rb

Constant Summary collapse

MSG =
"Prefer `render` with string instead of symbol"

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



35
36
37
38
39
# File 'lib/rubocop/cop/github/rails_controller_render_action_symbol.rb', line 35

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.source_range, "\"#{node.children[0]}\"")
  end
end

#on_send(node) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rubocop/cop/github/rails_controller_render_action_symbol.rb', line 23

def on_send(node)
  if sym_node = render_sym?(node)
    add_offense(sym_node, :expression)
  elsif option_pairs = render_with_options?(node)
    option_pairs.each do |pair|
      if sym_node = action_key?(pair)
        add_offense(sym_node, :expression)
      end
    end
  end
end