Skip to content

Commit

Permalink
Ruby2.7 warns on Proc.new with no block (#2059)
Browse files Browse the repository at this point in the history
* Ruby2.7 warns on Proc.new with no block
* sqs poller diff
* code-gen diff
  • Loading branch information
cjyclaire committed May 30, 2019
1 parent c6f9c46 commit d98d94c
Show file tree
Hide file tree
Showing 25 changed files with 86 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ module {{module_name}}

{{#types}}
def on_{{.}}_event(&block)
@event_emitter.on(:{{.}}, Proc.new)
@event_emitter.on(:{{.}}, block) if block_given?
end

{{/types}}
def on_error_event(&block)
@event_emitter.on(:error, Proc.new)
@event_emitter.on(:error, block) if block_given?
end

def on_initial_response_event(&block)
@event_emitter.on(:initial_response, Proc.new)
@event_emitter.on(:initial_response, block) if block_given?
end

def on_event(&block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ module {{module_name}}
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [{{class_name}}]
def wait_until_{{name}}(options = {})
def wait_until_{{name}}(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::{{waiter_class_name}}.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
{{#wait_call}}
{{#lines}}
{{{.}}}{{/lines}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [AutoScalingGroup]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::GroupExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(auto_scaling_group_names: [@name]))
AutoScalingGroup.new({
name: @name,
Expand All @@ -246,10 +246,10 @@ def wait_until_exists(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [AutoScalingGroup]
def wait_until_in_service(options = {})
def wait_until_in_service(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::GroupInService.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(auto_scaling_group_names: [@name]))
AutoScalingGroup.new({
name: @name,
Expand All @@ -263,10 +263,10 @@ def wait_until_in_service(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [AutoScalingGroup]
def wait_until_not_exists(options = {})
def wait_until_not_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::GroupNotExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(auto_scaling_group_names: [@name]))
AutoScalingGroup.new({
name: @name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Stack]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::StackExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(stack_name: @name))
Stack.new({
name: @name,
Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-cloudwatch/lib/aws-sdk-cloudwatch/alarm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Alarm]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::AlarmExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(alarm_names: [@name]))
Alarm.new({
name: @name,
Expand Down
2 changes: 2 additions & 0 deletions gems/aws-sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Mirgate Proc.new without a block usage #2058.

3.54.1 (2019-05-30)
------------------

Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-core/lib/aws-sdk-core/waiters/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def initialize(options = {})
#
# @yieldparam [Integer] attempts The number of attempts made.
def before_attempt(&block)
@before_attempt << Proc.new
@before_attempt << block if block_given?
end

# Register a callback that is invoked after an attempt but before
Expand Down Expand Up @@ -81,7 +81,7 @@ def before_attempt(&block)
# @yieldparam [Seahorse::Client::Response] response The response from
# the previous polling attempts.
def before_wait(&block)
@before_wait << Proc.new
@before_wait << block if block_given?
end

# @option options [Client] :client
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-core/lib/seahorse/client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def initialize
#
# @return [self]
def add_option(name, default = nil, &block)
default = DynamicDefault.new(Proc.new) if block_given?
default = DynamicDefault.new(block) if block_given?
@defaults[name.to_sym] << default
self
end
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-core/lib/seahorse/client/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(*args)

def emit(event_name, *args, &block)
@listeners[event_name] ||= []
@listeners[event_name] << Proc.new
@listeners[event_name] << block if block_given?
end

def signal(event, *args)
Expand Down
6 changes: 3 additions & 3 deletions gems/aws-sdk-core/lib/seahorse/client/http/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def signal_error(networking_error)
end

def on_headers(status_code_range = nil, &block)
@listeners[:headers] << listener(status_code_range, Proc.new)
@listeners[:headers] << listener(status_code_range, block)
end

def on_data(&callback)
@listeners[:data] << Proc.new
@listeners[:data] << callback
end

def on_done(status_code_range = nil, &callback)
listener = listener(status_code_range, Proc.new)
listener = listener(status_code_range, callback)
if @done
listener.call
else
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-core/lib/seahorse/client/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def option(name, default = nil, options = {}, &block)
else
options[:default] = default
end
options[:default_block] = Proc.new if block_given?
options[:default_block] = block if block_given?
self.options << PluginOption.new(name, options)
end

Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-ec2/lib/aws-sdk-ec2/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Image]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::ImageExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(image_ids: [@id]))
Image.new({
id: @id,
Expand Down
16 changes: 8 additions & 8 deletions gems/aws-sdk-ec2/lib/aws-sdk-ec2/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Instance]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::InstanceExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(instance_ids: [@id]))
Instance.new({
id: @id,
Expand All @@ -392,10 +392,10 @@ def wait_until_exists(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Instance]
def wait_until_running(options = {})
def wait_until_running(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::InstanceRunning.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(instance_ids: [@id]))
Instance.new({
id: @id,
Expand All @@ -410,10 +410,10 @@ def wait_until_running(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Instance]
def wait_until_stopped(options = {})
def wait_until_stopped(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::InstanceStopped.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(instance_ids: [@id]))
Instance.new({
id: @id,
Expand All @@ -428,10 +428,10 @@ def wait_until_stopped(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Instance]
def wait_until_terminated(options = {})
def wait_until_terminated(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::InstanceTerminated.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(instance_ids: [@id]))
Instance.new({
id: @id,
Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-ec2/lib/aws-sdk-ec2/snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ def data_loaded?
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Snapshot]
def wait_until_completed(options = {})
def wait_until_completed(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::SnapshotCompleted.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(snapshot_ids: [@id]))
Snapshot.new({
id: @id,
Expand Down
8 changes: 4 additions & 4 deletions gems/aws-sdk-ec2/lib/aws-sdk-ec2/vpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Vpc]
def wait_until_available(options = {})
def wait_until_available(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::VpcAvailable.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(vpc_ids: [@id]))
Vpc.new({
id: @id,
Expand All @@ -158,10 +158,10 @@ def wait_until_available(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [Vpc]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::VpcExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(vpc_ids: [@id]))
Vpc.new({
id: @id,
Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-ec2/lib/aws-sdk-ec2/vpc_peering_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [VpcPeeringConnection]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::VpcPeeringConnectionExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
resp = waiter.wait(params.merge(vpc_peering_connection_ids: [@id]))
VpcPeeringConnection.new({
id: @id,
Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-iam/lib/aws-sdk-iam/instance_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [InstanceProfile]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::InstanceProfileExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(instance_profile_name: @name))
InstanceProfile.new({
name: @name,
Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-iam/lib/aws-sdk-iam/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ def exists?(options = {})
# @option options [Proc] :before_attempt
# @option options [Proc] :before_wait
# @return [User]
def wait_until_exists(options = {})
def wait_until_exists(options = {}, &block)
options, params = separate_params_and_options(options)
waiter = Waiters::UserExists.new(options)
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
yield_waiter_and_warn(waiter, &block) if block_given?
waiter.wait(params.merge(user_name: @name))
User.new({
name: @name,
Expand Down
24 changes: 12 additions & 12 deletions gems/aws-sdk-kinesis/lib/aws-sdk-kinesis/event_streams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,51 @@ def initialize
end

def on_subscribe_to_shard_event_event(&block)
@event_emitter.on(:subscribe_to_shard_event, Proc.new)
@event_emitter.on(:subscribe_to_shard_event, block) if block_given?
end

def on_resource_not_found_exception_event(&block)
@event_emitter.on(:resource_not_found_exception, Proc.new)
@event_emitter.on(:resource_not_found_exception, block) if block_given?
end

def on_resource_in_use_exception_event(&block)
@event_emitter.on(:resource_in_use_exception, Proc.new)
@event_emitter.on(:resource_in_use_exception, block) if block_given?
end

def on_kms_disabled_exception_event(&block)
@event_emitter.on(:kms_disabled_exception, Proc.new)
@event_emitter.on(:kms_disabled_exception, block) if block_given?
end

def on_kms_invalid_state_exception_event(&block)
@event_emitter.on(:kms_invalid_state_exception, Proc.new)
@event_emitter.on(:kms_invalid_state_exception, block) if block_given?
end

def on_kms_access_denied_exception_event(&block)
@event_emitter.on(:kms_access_denied_exception, Proc.new)
@event_emitter.on(:kms_access_denied_exception, block) if block_given?
end

def on_kms_not_found_exception_event(&block)
@event_emitter.on(:kms_not_found_exception, Proc.new)
@event_emitter.on(:kms_not_found_exception, block) if block_given?
end

def on_kms_opt_in_required_event(&block)
@event_emitter.on(:kms_opt_in_required, Proc.new)
@event_emitter.on(:kms_opt_in_required, block) if block_given?
end

def on_kms_throttling_exception_event(&block)
@event_emitter.on(:kms_throttling_exception, Proc.new)
@event_emitter.on(:kms_throttling_exception, block) if block_given?
end

def on_internal_failure_exception_event(&block)
@event_emitter.on(:internal_failure_exception, Proc.new)
@event_emitter.on(:internal_failure_exception, block) if block_given?
end

def on_error_event(&block)
@event_emitter.on(:error, Proc.new)
@event_emitter.on(:error, block) if block_given?
end

def on_initial_response_event(&block)
@event_emitter.on(:initial_response, Proc.new)
@event_emitter.on(:initial_response, block) if block_given?
end

def on_event(&block)
Expand Down
Loading

0 comments on commit d98d94c

Please sign in to comment.