Sha256: 28ee5bbadfa06452070f9d287731acdb3af934334994c3d4c3014d71e1c2aa6a

Contents?: true

Size: 661 Bytes

Versions: 29

Compression:

Stored size: 661 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, location: :expression)
            end
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
rubocop-springest-0.7.5 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.7.4 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.7.3 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.7.2 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.16.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.15.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.7.1 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.14.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.7.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.9 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.8 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.13.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.7 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.6 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.5 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.4 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.3 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.12.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-github-0.11.0 lib/rubocop/cop/github/rails_render_inline.rb
rubocop-springest-0.6.2 lib/rubocop/cop/github/rails_render_inline.rb