Sha256: c583a7b6d3f9efe5eba98c43a6b5aaa21c62db438adc42d033c15b2b01326eac
Contents?: true
Size: 813 Bytes
Versions: 2
Compression:
Stored size: 813 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Rails # 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 } class DefaultScope < Cop MSG = 'default_scope expects a block as its sole argument.' def on_send(node) return unless command?(:default_scope, node) _receiver, _method_name, *args = *node return unless args.size == 1 first_arg = args[0] if first_arg.type != :block || lambda_or_proc?(first_arg) add_offense(first_arg, :expression) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/rails/default_scope.rb |
rubocop-0.19.0 | lib/rubocop/cop/rails/default_scope.rb |