Class: RuboCop::Cop::GoogleAds::DoNotGetResourceMethods

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/google_ads/do_not_get_resource_methods.rb

Overview

This cop enforces to use GoogleAdsService.search to retrive resource.

Examples:

# bad
client.service.resource.get_resource

# good
client.service.google_ads.search(customer_id, query_to_retrive_resource)

Constant Summary collapse

DEPRECATED_GET_METHODS =
YAML.parse(deprecated_get_methods_file_path).to_ruby.map(&:to_sym).freeze
MSG =
'Use `GoogleAdsService.search`, instead of get methods.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



21
22
23
24
25
26
# File 'lib/rubocop/cop/google_ads/do_not_get_resource_methods.rb', line 21

def on_send(node)
  receiver, method_name = *node
  return unless receiver && DEPRECATED_GET_METHODS.include?(method_name)

  add_offense(node, location: :selector)
end