Class: RuboCop::Cop::Sequioacap::RailsControllerRenderActionSymbol
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Sequioacap::RailsControllerRenderActionSymbol
- Defined in:
- lib/rubocop/cop/sequioacap/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
36 37 38 39 40 |
# File 'lib/rubocop/cop/sequioacap/rails_controller_render_action_symbol.rb', line 36 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 34 |
# File 'lib/rubocop/cop/sequioacap/rails_controller_render_action_symbol.rb', line 23 def on_send(node) sym_node = render_sym?(node) option_pairs = (node) if sym_node add_offense(sym_node, location: :expression) elsif option_pairs option_pairs.each do |pair| sym_node = action_key?(pair) add_offense(sym_node, location: :expression) if sym_node end end end |