Sha256: 8e5f80edc4799ad839a3899190576f1f52e451c6b7f74c52f1f55f2701664352

Contents?: true

Size: 650 Bytes

Versions: 6

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

require "rubocop"

module RuboCop
  module Cop
    module GitHub
      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, :expression)
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rubocop-shakr-0.6.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-shakr-0.5.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.5.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-shakr-0.1.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.4.2 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.4.1 lib/rubocop/cop/github/rails_render_inline.rb