Sha256: 4092584282f50a17186be3b9dafdb9f54f13dc80ac7e8839d4dd6f8e6cbce3ec

Contents?: true

Size: 663 Bytes

Versions: 3

Compression:

Stored size: 663 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)
            if option_pairs.detect { |pair| inline_key?(pair) }
              add_offense(node, location: :expression)
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-standard-1.15.1 lib/rubocop/cop/standard/rails_render_inline.rb
rubocop-standard-1.15.0 lib/rubocop/cop/standard/rails_render_inline.rb
rubocop-standard-1.14.0 lib/rubocop/cop/standard/rails_render_inline.rb