Sha256: 354b3b613f2629942db8e1c2a09f7705759535969ee286165b4125995d20b653

Contents?: true

Size: 633 Bytes

Versions: 4

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

require 'rubocop'

module RuboCop
  module Cop
    module Standard
      class RailsRenderInline < Cop
        MSG = 'Avoid `render inline:`'

        def_node_matcher :render_with_options?, <<-PATTERN
          (send nil? :render (hash $...))
        PATTERN

        def_node_matcher :inline_key?, <<-PATTERN
          (pair (sym :inline) $_)
        PATTERN

        def on_send(node)
          if option_pairs = render_with_options?(node)
            add_offense(node, location: :expression) if option_pairs.detect { |pair| inline_key?(pair) }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-standard-2.1.1 lib/rubocop/cop/standard/rails_render_inline.rb
rubocop-standard-2.1.0 lib/rubocop/cop/standard/rails_render_inline.rb
rubocop-standard-2.0.1 lib/rubocop/cop/standard/rails_render_inline.rb
rubocop-standard-2.0 lib/rubocop/cop/standard/rails_render_inline.rb