Class: RuboCop::Cop::GitHub::RailsViewRenderLiteral

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

Constant Summary collapse

MSG =
"render must be used with a string literal"

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rubocop/cop/github/rails_view_render_literal.rb', line 41

def on_send(node)
  return unless render?(node)

  if render_literal?(node)
  elsif option_pairs = render_with_options?(node)
    if option_pairs.any? { |pair| ignore_key?(pair) }
      return
    end

    if partial_node = option_pairs.map { |pair| partial_key?(pair) }.compact.first
      if !literal?(partial_node)
        add_offense(node, :expression)
      end
    else
      add_offense(node, :expression)
    end
  else
    add_offense(node, :expression)
  end
end