Class: RuboCop::Cop::Rails::ScopeArgs
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Rails::ScopeArgs
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rails/scope_args.rb
Overview
Checks for scope calls where it was passed a method (usually a scope) instead of a lambda/proc.
Constant Summary collapse
- MSG =
'Use `lambda`/`proc` instead of a plain method call.'
- RESTRICT_ON_SEND =
%i[scope].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
24 25 26 27 28 29 30 |
# 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 |