Skip to content

Commit b63e27d

Browse files
authored
chore: More fixes to conform to the upcoming Rubocop update (#9897)
1 parent 940404e commit b63e27d

15 files changed

Lines changed: 95 additions & 117 deletions

File tree

‎google-cloud-container_analysis/samples/acceptance/sample_test.rb‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,20 @@ def new_note_id
3232
before do
3333
test_name = name.tr " ", "-"
3434
uuid = SecureRandom.uuid
35-
@image_url = "https://gcr.io/" + test_name + "/" + uuid
35+
@image_url = "https://gcr.io/#{test_name}/#{uuid}"
3636
@project_id = ENV["GOOGLE_CLOUD_PROJECT"]
3737
@try_limit = 10
3838
@sleep_time = 1
39-
@subscription_id = "occurrence-subscription-" + uuid
39+
@subscription_id = "occurrence-subscription-#{uuid}"
4040
@uuid = uuid
4141
@note_ids_to_delete = []
4242
end
4343

4444
after do
4545
@note_ids_to_delete.each do |note_id|
46-
begin
47-
delete_note project_id: @project_id, note_id: note_id
48-
rescue StandardError
49-
puts "Failed to delete #{note_id}"
50-
end
46+
delete_note project_id: @project_id, note_id: note_id
47+
rescue StandardError
48+
puts "Failed to delete #{note_id}"
5149
end
5250
end
5351

‎google-cloud-datastore-admin-v1/samples/Gemfile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ source "https://rubygems.org"
2020
if ENV["GOOGLE_CLOUD_SAMPLES_TEST"] == "master"
2121
gem "google-cloud-datastore-admin-v1", path: "../../google-cloud-datastore-admin-v1"
2222
else
23-
# rubocop:disable Bundler/DuplicatedGem
2423
# [START datastore_admin_dependencies]
2524
gem "google-cloud-datastore-admin-v1"
2625
# [END datastore_admin_dependencies]
27-
# rubocop:enable Bundler/DuplicatedGem
2826
end
2927

3028
group :test do

‎google-cloud-datastore-admin-v1/samples/acceptance/snippets_test.rb‎

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,27 @@
4545
end
4646

4747
it "entities_export, entities_import" do
48-
begin
49-
op = nil
50-
out, _err = capture_io do
51-
op = entities_export project_id: project_id, output_url_prefix: output_url_prefix
52-
end
53-
assert_includes out, "Entities were exported"
54-
assert op
55-
assert op.response
56-
assert_equal "#{output_url_prefix}/#{storage_file_prefix}.overall_export_metadata", op.response.output_url
48+
op = nil
49+
out, _err = capture_io do
50+
op = entities_export project_id: project_id, output_url_prefix: output_url_prefix
51+
end
52+
assert_includes out, "Entities were exported"
53+
assert op
54+
assert op.response
55+
assert_equal "#{output_url_prefix}/#{storage_file_prefix}.overall_export_metadata", op.response.output_url
5756

58-
out, _err = capture_io do
59-
entities_import project_id: project_id, input_url: op.response.output_url
60-
end
61-
assert_includes out, "Entities were imported"
62-
ensure
63-
# cleanup: delete exported objects
64-
require "google/cloud/storage"
65-
storage = Google::Cloud::Storage.new
66-
files = storage.bucket(storage_bucket_name).files prefix: storage_file_prefix
67-
files.each do |f|
68-
f.delete
69-
puts "Deleted: #{f.name}"
70-
end
57+
out, _err = capture_io do
58+
entities_import project_id: project_id, input_url: op.response.output_url
59+
end
60+
assert_includes out, "Entities were imported"
61+
ensure
62+
# cleanup: delete exported objects
63+
require "google/cloud/storage"
64+
storage = Google::Cloud::Storage.new
65+
files = storage.bucket(storage_bucket_name).files prefix: storage_file_prefix
66+
files.each do |f|
67+
f.delete
68+
puts "Deleted: #{f.name}"
7169
end
7270
end
7371
end

‎google-cloud-dialogflow/samples/acceptance/helper.rb‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def get_entity_type_ids project_id:, display_name:
2424

2525
selected_entity_types = entity_types.select { |entity_type| entity_type.display_name == display_name }
2626

27-
entity_type_ids = selected_entity_types.map { |entity_type| entity_type.name.split("/").last }
28-
29-
entity_type_ids
27+
selected_entity_types.map { |entity_type| entity_type.name.split("/").last }
3028
end
3129

3230
def clean_entity_types project_id:, display_name:
@@ -46,9 +44,7 @@ def get_intent_ids project_id:, display_name:
4644

4745
selected_intents = intents.select { |intent| intent.display_name == display_name }
4846

49-
intent_ids = selected_intents.map { |intent| intent.name.split("/").last }
50-
51-
intent_ids
47+
selected_intents.map { |intent| intent.name.split("/").last }
5248
end
5349

5450
def clean_intents project_id:, display_name:

‎google-cloud-kms/samples/Gemfile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ source "https://rubygems.org"
2020
if ENV["GOOGLE_CLOUD_SAMPLES_TEST"] == "master"
2121
gem "google-cloud-kms", path: "../../google-cloud-kms"
2222
else
23-
# rubocop:disable Bundler/DuplicatedGem
2423
# [START kms_dependencies]
2524
gem "google-cloud-kms"
2625
# [END kms_dependencies]
27-
# rubocop:enable Bundler/DuplicatedGem
2826
end
2927

3028
group :test do

‎google-cloud-scheduler/samples/app.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
STDOUT.sync = true
17+
$stdout.sync = true
1818

1919
# [START cloud_scheduler_app]
2020
require "sinatra"

‎google-cloud-security_center/samples/acceptance/helper.rb‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
def retry_resource_exhaustion
2222
last_error = nil
2323
5.times do
24-
begin
25-
return yield
26-
rescue Google::Cloud::ResourceExhaustedError => e
27-
last_error = e
28-
puts "\n#{e} Gonna try again"
29-
sleep rand(1..5)
30-
end
24+
return yield
25+
rescue Google::Cloud::ResourceExhaustedError => e
26+
last_error = e
27+
puts "\n#{e} Gonna try again"
28+
sleep rand(1..5)
3129
end
3230
raise last_error
3331
end

‎google-cloud-security_center/samples/acceptance/notification_test.rb‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,18 @@ def cleanup!
4141
def create_fixture!
4242
last_error = nil
4343
3.times do
44-
begin
45-
create_notification_config org_id: @org_id,
46-
config_id: @config_id,
47-
pubsub_topic: @pubsub_topic
48-
return
49-
rescue Google::Cloud::FailedPreconditionError => e
50-
# Creating this fixture occasionally raises a precondition error.
51-
# I'm not certain why, but because we can have tests running
52-
# concurrently, I suspect it happens when multiple fixtures are being
53-
# created simultaneously. Retry with a random delay if this happens.
54-
puts "Got precondition error when creating fixture #{@config_id}"
55-
sleep rand(2.0..7.0)
56-
last_error = e
57-
end
44+
create_notification_config org_id: @org_id,
45+
config_id: @config_id,
46+
pubsub_topic: @pubsub_topic
47+
return
48+
rescue Google::Cloud::FailedPreconditionError => e
49+
# Creating this fixture occasionally raises a precondition error.
50+
# I'm not certain why, but because we can have tests running
51+
# concurrently, I suspect it happens when multiple fixtures are being
52+
# created simultaneously. Retry with a random delay if this happens.
53+
puts "Got precondition error when creating fixture #{@config_id}"
54+
sleep rand(2.0..7.0)
55+
last_error = e
5856
end
5957
raise last_error
6058
end

‎google-cloud-talent/samples/acceptance/helper.rb‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,10 @@ def get_company_helper company_name
137137

138138
def timed_retry
139139
5.times do
140-
begin
141-
return yield
142-
rescue StandardError => e
143-
puts "\n#{e} Gonna try again"
144-
sleep 5
145-
end
140+
return yield
141+
rescue StandardError => e
142+
puts "\n#{e} Gonna try again"
143+
sleep 5
146144
end
147145
raise Google::Cloud::NotFoundError
148146
end

‎google-cloud-talent/samples/acceptance/talent_test.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
address,
8181
language_code
8282
end
83-
matches = out.scan(/\sname:\s\"([^\"]*)\"/).flatten
83+
matches = out.scan(/\sname:\s"([^"]*)"/).flatten
8484
assert_equal matches.size, 2
8585
matches.each { |job_match| assert get_job_helper(job_match) }
8686
end

0 commit comments

Comments
 (0)