From 38ec5e6d4645c42dee6f6e45095bd01bfcaf332e Mon Sep 17 00:00:00 2001 From: Richard Wang Date: Tue, 26 May 2026 13:45:41 -0700 Subject: [PATCH] Rubocop --- .../lib/smithy-client/dynamic_errors.rb | 2 +- .../lib/smithy-client/net_http/handler.rb | 4 ++-- .../lib/smithy-client/param_converter.rb | 2 +- .../spec/smithy-client/param_converter_spec.rb | 15 ++++++++------- .../lib/smithy/views/client/operation_examples.rb | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gems/smithy-client/lib/smithy-client/dynamic_errors.rb b/gems/smithy-client/lib/smithy-client/dynamic_errors.rb index 9cb606c86..3a1410590 100644 --- a/gems/smithy-client/lib/smithy-client/dynamic_errors.rb +++ b/gems/smithy-client/lib/smithy-client/dynamic_errors.rb @@ -74,7 +74,7 @@ def set_error_constant(constant) # rubocop:disable Naming/AccessorMethodName def error_const_set?(constant) # Purposefully not using #const_defined? as that method returns true # for constants not defined directly in the current module. - constants.include?(constant.to_sym) + const_defined?(constant.to_sym) end end end diff --git a/gems/smithy-client/lib/smithy-client/net_http/handler.rb b/gems/smithy-client/lib/smithy-client/net_http/handler.rb index 180f5628a..c8d4f049e 100644 --- a/gems/smithy-client/lib/smithy-client/net_http/handler.rb +++ b/gems/smithy-client/lib/smithy-client/net_http/handler.rb @@ -101,8 +101,8 @@ def pool_for(config) # @param [Configuration] config # @return [Hash] def pool_options(config) - ConnectionPool::OPTIONS.keys.each_with_object({}) do |opt, opts| - opts[opt] = config.send(opt) + ConnectionPool::OPTIONS.keys.to_h do |opt| + [opt, config.send(opt)] end end diff --git a/gems/smithy-client/lib/smithy-client/param_converter.rb b/gems/smithy-client/lib/smithy-client/param_converter.rb index 6dc819e3e..f89eb0237 100644 --- a/gems/smithy-client/lib/smithy-client/param_converter.rb +++ b/gems/smithy-client/lib/smithy-client/param_converter.rb @@ -113,7 +113,7 @@ def add(shape_class, value_class, &block) def ensure_open(file, converter) if file.closed? - new_file = File.open(file.path, 'rb') + new_file = File.open(file.path, 'rb') # rubocop:disable Style/FileOpen converter.opened_files << new_file new_file else diff --git a/gems/smithy-client/spec/smithy-client/param_converter_spec.rb b/gems/smithy-client/spec/smithy-client/param_converter_spec.rb index befcaa8b4..1f525e1e8 100644 --- a/gems/smithy-client/spec/smithy-client/param_converter_spec.rb +++ b/gems/smithy-client/spec/smithy-client/param_converter_spec.rb @@ -121,9 +121,9 @@ module Client end it 'accepts io objects (like file)' do - file = File.open(__FILE__, 'r') - expect(ParamConverter.c(shape_class, file)).to be(file) - file.close + File.open(__FILE__, 'r') do |file| + expect(ParamConverter.c(shape_class, file)).to be(file) + end end it 'accepts io objects (like stringio)' do @@ -143,10 +143,11 @@ module Client end it 'opens files that are closed' do - file = File.open(__FILE__, 'r') - file.close - converter = ParamConverter.new(nil) - expect(ParamConverter.c(shape_class, file, converter).read).to eq(File.read(__FILE__)) + File.open(__FILE__, 'r') do |file| + file.close + converter = ParamConverter.new(nil) + expect(ParamConverter.c(shape_class, file, converter).read).to eq(File.read(__FILE__)) + end end end diff --git a/gems/smithy/lib/smithy/views/client/operation_examples.rb b/gems/smithy/lib/smithy/views/client/operation_examples.rb index 9f35c7ea2..b54c78667 100644 --- a/gems/smithy/lib/smithy/views/client/operation_examples.rb +++ b/gems/smithy/lib/smithy/views/client/operation_examples.rb @@ -136,7 +136,7 @@ def format(shape_val) formatted = [] if shape_val.is_a?(Array) hashes = shape_val.map do |v| - (v.is_a?(Hash) ? format_hash(v, ' ') : v) + v.is_a?(Hash) ? format_hash(v, ' ') : v end hashes.join(',') formatted << hashes