class RuboCop::Cop::Rails::ScopeArgs

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) }

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/rails/scope_args.rb, line 24
def on_send(node)
  scope?(node) do |second_arg|
    add_offense(second_arg) do |corrector|
      corrector.replace(second_arg, "-> { #{second_arg.source} }")
    end
  end
end