Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Rails::DefaultScope

This cop checks for default_scope calls when it was passed a lambda or a proc instead of a block.

@example

# incorrect
default_scope -> { something }

# correct
default_scope { something }

Constants

MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/rails/default_scope.rb, line 18
def on_send(node)
  return unless command?(:default_scope, node)

  _receiver, _method_name, *args = *node
  return unless args.size == 1

  first_arg = args[0]
  return unless first_arg.type != :block || lambda_or_proc?(first_arg)

  add_offense(first_arg, :expression)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.