Sha256: f46fbbb667eda70f42bc8966b17195b9ae7e1fdf97d99d8c27a3cc474c096b25

Contents?: true

Size: 696 Bytes

Versions: 22

Compression:

Stored size: 696 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rails
      # This cop checks for scope calls where it was passed
      # a method (usually a scope) instead of a lambda/proc.
      #
      # @example
      #
      #   # bad
      #   scope :something, where(something: true)
      #
      #   # good
      #   scope :something, -> { where(something: true) }
      class ScopeArgs < Cop
        MSG = 'Use `lambda`/`proc` instead of a plain method call.'

        def_node_matcher :scope?, '(send nil? :scope _ $send)'

        def on_send(node)
          scope?(node) do |second_arg|
            add_offense(second_arg)
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rubocop-rails-2.8.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.8.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.7.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.7.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.6.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.5.2 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.5.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.5.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.4.2 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.4.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.4.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.3.2 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.3.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.3.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.2.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.2.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.1.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.0.1 lib/rubocop/cop/rails/scope_args.rb
rubocop-0.71.0 lib/rubocop/cop/rails/scope_args.rb
rubocop-rails-2.0.0 lib/rubocop/cop/rails/scope_args.rb