Module: RuboCop::Cop::Rails::RedundantActiveRecordAllMethod::AllowedReceivers
- Included in:
- RuboCop::Cop::Rails::RedundantActiveRecordAllMethod
- Defined in:
- lib/rubocop/cop/rails/redundant_active_record_all_method.rb
Overview
TODO: In the future, please support only RuboCop 1.52+ and use ‘RuboCop::Cop::AllowedReceivers`:
https://github.com/rubocop/rubocop/blob/v1.52.0/lib/rubocop/cop/mixin/allowed_receivers.rb
At that time, this duplicated module implementation can be removed.
Instance Method Summary collapse
- #allowed_receiver?(receiver) ⇒ Boolean
- #allowed_receivers ⇒ Object
- #receiver_name(receiver) ⇒ Object
Instance Method Details
#allowed_receiver?(receiver) ⇒ Boolean
180 181 182 183 184 |
# File 'lib/rubocop/cop/rails/redundant_active_record_all_method.rb', line 180 def allowed_receiver?(receiver) receiver_name = receiver_name(receiver) allowed_receivers.include?(receiver_name) end |
#allowed_receivers ⇒ Object
200 201 202 |
# File 'lib/rubocop/cop/rails/redundant_active_record_all_method.rb', line 200 def allowed_receivers cop_config.fetch('AllowedReceivers', []) end |
#receiver_name(receiver) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/rubocop/cop/rails/redundant_active_record_all_method.rb', line 186 def receiver_name(receiver) return receiver_name(receiver.receiver) if receiver.receiver && !receiver.receiver.const_type? if receiver.send_type? if receiver.receiver "#{receiver_name(receiver.receiver)}.#{receiver.method_name}" else receiver.method_name.to_s end else receiver.source end end |