rubocop-google_ads 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9fa293a81fb19cf2a475155458f2b4cd378927e392950a47641f46924d9bb333
4
+ data.tar.gz: 584a02dcdd660daaf8b2975b3851c5e6f13ec24b09c5cb9af68d74795369ece7
5
+ SHA512:
6
+ metadata.gz: f76d1a6c8bc82a06b96e3bcb53ddaf297579c5e87b5e01a9125c50f4c873f1c6e5cdcaee74e5e08dd5eeb6b10efbea2ae5f161e3651fc7c45dd9e1a8c3afdc1b
7
+ data.tar.gz: a2f39debec957f3284626fdd0615e1685c12556e0b36248143a6ea4456d2cd72fb9037055ae01902c3a3a9bd4c3e85a8b31e8428831b69e32707afb5c846d333
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ Naming/FileName:
2
+ Exclude:
3
+ - lib/rubocop-google_ads.rb
4
+
5
+ Metrics/ClassLength:
6
+ Enabled: false
7
+
8
+ Style/Documentation:
9
+ Enabled: false
10
+
11
+ Layout/LineLength:
12
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.5
6
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Change log
2
+
3
+ ## 0.1.0
4
+
5
+ ### New features
6
+
7
+ - Add new `GoogleAds/DoNotGetResourceMethods` cop.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in rubocop-google_ads.gemspec
6
+ gemspec
7
+
8
+ gem 'google-ads-googleads'
9
+ gem 'pry-byebug'
10
+ gem 'rake', '~> 12.0'
11
+ gem 'rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubocop-google_ads (0.1.0)
5
+ rubocop
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.0)
13
+ byebug (11.1.1)
14
+ coderay (1.1.2)
15
+ diff-lcs (1.3)
16
+ faraday (0.17.3)
17
+ multipart-post (>= 1.2, < 3)
18
+ google-ads-googleads (4.0.0)
19
+ google-gax (~> 1.6)
20
+ google-gax (1.8.1)
21
+ google-protobuf (~> 3.9)
22
+ googleapis-common-protos (>= 1.3.9, < 2.0)
23
+ googleauth (~> 0.9)
24
+ grpc (~> 1.24)
25
+ rly (~> 0.2.3)
26
+ google-protobuf (3.11.3)
27
+ googleapis-common-protos (1.3.9)
28
+ google-protobuf (~> 3.0)
29
+ googleapis-common-protos-types (~> 1.0)
30
+ grpc (~> 1.0)
31
+ googleapis-common-protos-types (1.0.4)
32
+ google-protobuf (~> 3.0)
33
+ googleauth (0.10.0)
34
+ faraday (~> 0.12)
35
+ jwt (>= 1.4, < 3.0)
36
+ memoist (~> 0.16)
37
+ multi_json (~> 1.11)
38
+ os (>= 0.9, < 2.0)
39
+ signet (~> 0.12)
40
+ grpc (1.27.0)
41
+ google-protobuf (~> 3.11)
42
+ googleapis-common-protos-types (~> 1.0)
43
+ jaro_winkler (1.5.4)
44
+ jwt (2.2.1)
45
+ memoist (0.16.2)
46
+ method_source (0.9.2)
47
+ multi_json (1.14.1)
48
+ multipart-post (2.1.1)
49
+ os (1.0.1)
50
+ parallel (1.19.1)
51
+ parser (2.7.0.2)
52
+ ast (~> 2.4.0)
53
+ pry (0.12.2)
54
+ coderay (~> 1.1.0)
55
+ method_source (~> 0.9.0)
56
+ pry-byebug (3.8.0)
57
+ byebug (~> 11.0)
58
+ pry (~> 0.10)
59
+ public_suffix (4.0.3)
60
+ rainbow (3.0.0)
61
+ rake (12.3.3)
62
+ rly (0.2.3)
63
+ rspec (3.9.0)
64
+ rspec-core (~> 3.9.0)
65
+ rspec-expectations (~> 3.9.0)
66
+ rspec-mocks (~> 3.9.0)
67
+ rspec-core (3.9.1)
68
+ rspec-support (~> 3.9.1)
69
+ rspec-expectations (3.9.0)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.9.0)
72
+ rspec-mocks (3.9.1)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.9.0)
75
+ rspec-support (3.9.2)
76
+ rubocop (0.79.0)
77
+ jaro_winkler (~> 1.5.1)
78
+ parallel (~> 1.10)
79
+ parser (>= 2.7.0.1)
80
+ rainbow (>= 2.2.2, < 4.0)
81
+ ruby-progressbar (~> 1.7)
82
+ unicode-display_width (>= 1.4.0, < 1.7)
83
+ ruby-progressbar (1.10.1)
84
+ signet (0.12.0)
85
+ addressable (~> 2.3)
86
+ faraday (~> 0.9)
87
+ jwt (>= 1.5, < 3.0)
88
+ multi_json (~> 1.10)
89
+ unicode-display_width (1.6.1)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ google-ads-googleads
96
+ pry-byebug
97
+ rake (~> 12.0)
98
+ rspec
99
+ rubocop-google_ads!
100
+
101
+ BUNDLED WITH
102
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 hanocha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Rubocop::GoogleAds
2
+
3
+ A RuboCop extension for [Google Ads Client Library for Ruby](https://github.com/googleads/google-ads-ruby).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rubocop-google_ads', require: false
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rubocop-google_ads
20
+
21
+ ## Usage
22
+
23
+ Require it in your `.rubocop.yml`, like below.
24
+
25
+ ```
26
+ require: rubocop-rails
27
+ ```
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hanocha/rubocop-google_ads.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
9
+
10
+ require 'rspec/core/rake_task'
11
+
12
+ RSpec::Core::RakeTask.new(:spec) do |spec|
13
+ spec.pattern = FileList['spec/**/*_spec.rb']
14
+ end
15
+
16
+ desc 'Generate a new cop with a template'
17
+ task :new_cop, [:cop] do |_task, args|
18
+ require 'rubocop'
19
+
20
+ cop_name = args.fetch(:cop) do
21
+ warn 'usage: bundle exec rake new_cop[Department/Name]'
22
+ exit!
23
+ end
24
+
25
+ github_user = `git config github.user`.chop
26
+ github_user = 'your_id' if github_user.empty?
27
+
28
+ generator = RuboCop::Cop::Generator.new(cop_name, github_user)
29
+
30
+ generator.write_source
31
+ generator.write_spec
32
+ generator.inject_require(root_file_path: 'lib/rubocop/cop/google_ads_cops.rb')
33
+ generator.inject_config(config_file_path: 'config/default.yml')
34
+
35
+ puts generator.todo
36
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'rubocop/google_ads'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'pry'
15
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ GoogleAds/DoNotGetResourceMethods:
2
+ Description: 'Do not use get methods to fetch resource informations. Use GoogleAdsService.search.'
3
+ Enabled: true
4
+ VersionAdded: '0.1'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop'
4
+
5
+ require_relative 'rubocop/google_ads'
6
+ require_relative 'rubocop/google_ads/version'
7
+ require_relative 'rubocop/google_ads/inject'
8
+
9
+ RuboCop::GoogleAds::Inject.defaults!
10
+
11
+ require_relative 'rubocop/cop/google_ads_cops'
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TODO: when finished, run `rake generate_cops_documentation` to update the docs
4
+ module RuboCop
5
+ module Cop
6
+ module GoogleAds
7
+ # This cop enforces to use GoogleAdsService.search to retrive resource.
8
+ #
9
+ # @example
10
+ # # bad
11
+ # client.service.resource.get_resource
12
+ #
13
+ # # good
14
+ # client.service.google_ads.search(customer_id, query_to_retrive_resource)
15
+ #
16
+ class DoNotGetResourceMethods < Cop
17
+ DEPRECATED_GET_METHODS = %i[
18
+ get_ad_group_bid_modifier
19
+ get_group_placement_view
20
+ get_campaign_budget
21
+ get_extension_feed_item
22
+ get_customer_manager_link
23
+ get_search_term_view
24
+ get_keyword_plan_ad_group
25
+ get_billing_setup
26
+ get_click_view
27
+ get_shared_criterion
28
+ get_campaign_draft
29
+ get_ad_group_simulation
30
+ get_product_group_view
31
+ get_landing_page_view
32
+ get_campaign_shared_set
33
+ get_keyword_plan_keyword
34
+ get_location_view
35
+ get_custom_interest
36
+ get_merchant_center_link
37
+ get_detail_placement_view
38
+ get_customer_negative_criterion
39
+ get_keyword_plan_campaign
40
+ get_paid_organic_search_term_view
41
+ get_age_range_view
42
+ get_campaign_label
43
+ get_ad_group_audience_view
44
+ get_mobile_app_category_constant
45
+ get_topic_constant
46
+ get_parental_status_view
47
+ get_bidding_strategy
48
+ get_geo_target_constant
49
+ get_ad_parameter
50
+ get_mobile_device_constant
51
+ get_ad_group_ad_asset_view
52
+ get_ad_group_feed
53
+ get_ad_group_criterion_simulation
54
+ get_ad_group_criterion
55
+ get_distance_view
56
+ get_media_file
57
+ get_user_location_view
58
+ get_feed_item_target
59
+ get_carrier_constant
60
+ get_campaign_audience_view
61
+ get_hotel_group_view
62
+ get_feed_item
63
+ get_campaign_criterion_simulation
64
+ get_customer_client
65
+ get_ad_group_label
66
+ get_recommendation
67
+ get_ad_schedule_view
68
+ get_domain_category
69
+ get_keyword_plan_negative_keyword
70
+ get_ad_group_extension_setting
71
+ get_ad
72
+ get_ad_group_ad
73
+ get_keyword_plan
74
+ get_feed_placeholder_view
75
+ get_customer_client_link
76
+ get_mutate_job
77
+ get_dynamic_search_ads_search_term_view
78
+ get_feed_mapping
79
+ get_language_constant
80
+ get_feed
81
+ get_hotel_performance_view
82
+ get_campaign_criterion
83
+ get_campaign_bid_modifier
84
+ get_customer
85
+ get_remarketing_action
86
+ get_ad_group
87
+ get_label
88
+ get_customer_feed
89
+ get_shared_set
90
+ get_customer_extension_setting
91
+ get_account_budget
92
+ get_campaign_feed
93
+ get_gender_view
94
+ get_video
95
+ get_keyword_view
96
+ get_user_list
97
+ get_product_bidding_category_constant
98
+ get_topic_view
99
+ get_asset
100
+ get_campaign_experiment
101
+ get_conversion_action
102
+ get_ad_group_ad_label
103
+ get_change_status
104
+ get_campaign_extension_setting
105
+ get_operating_system_version_constant
106
+ get_ad_group_criterion_label
107
+ get_geographic_view
108
+ get_google_ads_field
109
+ get_campaign
110
+ get_user_interest
111
+ get_shopping_performance_view
112
+ get_expanded_landing_page_view
113
+ get_customer_label
114
+ get_display_keyword_view
115
+ get_managed_placement_view
116
+ get_account_budget_proposal
117
+ ].freeze
118
+
119
+ MSG = 'Use `GoogleAdsService.search`, instead of get methods.'
120
+
121
+ def on_send(node)
122
+ receiver, method_name = *node
123
+ return unless receiver && DEPRECATED_GET_METHODS.include?(method_name)
124
+
125
+ add_offense(node, location: :selector)
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'google_ads/do_not_get_resource_methods'
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'rubocop/google_ads/version'
5
+
6
+ module RuboCop
7
+ module GoogleAds
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
11
+ CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
12
+ CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
13
+
14
+ private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The original code is from https://github.com/rubocop-hq/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
4
+ # See https://github.com/rubocop-hq/rubocop-rspec/blob/master/MIT-LICENSE.md
5
+ module RuboCop
6
+ module GoogleAds
7
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
+ # bit of our configuration.
9
+ module Inject
10
+ def self.defaults!
11
+ path = CONFIG_DEFAULT.to_s
12
+ hash = ConfigLoader.send(:load_yaml_configuration, path)
13
+ config = Config.new(hash, path).tap(&:make_excludes_absolute)
14
+ puts "configuration from #{path}" if ConfigLoader.debug?
15
+ config = ConfigLoader.merge_with_default(config, path)
16
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module GoogleAds
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/rubocop/google_ads/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'rubocop-google_ads'
7
+ spec.version = RuboCop::GoogleAds::VERSION
8
+ spec.authors = ['hanocha']
9
+ spec.email = ['hanocha.peter@gmail.com']
10
+
11
+ spec.summary = 'Custom cops for Google Ads API Ruby Client Library'
12
+ spec.homepage = 'https://github.com/hanocha/rubocop-google_ads'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.5')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_runtime_dependency 'rubocop'
29
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-google_ads
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - hanocha
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - hanocha.peter@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - ".travis.yml"
38
+ - CHANGELOG.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/console
45
+ - bin/setup
46
+ - config/default.yml
47
+ - lib/rubocop-google_ads.rb
48
+ - lib/rubocop/cop/google_ads/do_not_get_resource_methods.rb
49
+ - lib/rubocop/cop/google_ads_cops.rb
50
+ - lib/rubocop/google_ads.rb
51
+ - lib/rubocop/google_ads/inject.rb
52
+ - lib/rubocop/google_ads/version.rb
53
+ - rubocop-google_ads.gemspec
54
+ homepage: https://github.com/hanocha/rubocop-google_ads
55
+ licenses:
56
+ - MIT
57
+ metadata:
58
+ homepage_uri: https://github.com/hanocha/rubocop-google_ads
59
+ source_code_uri: https://github.com/hanocha/rubocop-google_ads
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.6.5
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.0.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Custom cops for Google Ads API Ruby Client Library
79
+ test_files: []