diff options
author | Hiroshi SHIBATA <[email protected]> | 2023-03-16 13:47:12 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-03-17 18:50:55 +0900 |
commit | 6ad269dc39ab6bdf7ef195a048fa10b642374826 (patch) | |
tree | 6ba6dfbc3b6ecd67a10ae2cd4c8b5c6428838ce8 | |
parent | 70164eec0f48a691dd039f55ac897036aa32e5cf (diff) |
[rubygems/rubygems] util/rubocop -A --only Style/RescueStandardError
https://github.com/rubygems/rubygems/commit/80b57da926
23 files changed, 33 insertions, 33 deletions
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index da3e22ef1b..ab21013c2a 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -432,7 +432,7 @@ class Gem::Command begin parser.parse!(args.dup) return true - rescue + rescue StandardError return false end end diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb index e3c288d659..ff15fa11b0 100644 --- a/lib/rubygems/commands/check_command.rb +++ b/lib/rubygems/commands/check_command.rb @@ -42,7 +42,7 @@ class Gem::Commands::CheckCommand < Gem::Command say gems = begin get_all_gem_names - rescue + rescue StandardError [] end diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 0ef8c45e97..4751928682 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -98,7 +98,7 @@ permission to. action = method == :delete ? "Removing" : "Adding" with_response response, "#{action} #{owner}" - rescue + rescue StandardError # ignore end end diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb index 6025660498..fc2fb49ceb 100644 --- a/lib/rubygems/commands/specification_command.rb +++ b/lib/rubygems/commands/specification_command.rb @@ -108,7 +108,7 @@ Specific fields in the specification can be extracted in YAML format: if File.exist? gem begin specs << Gem::Package.new(gem).spec - rescue + rescue StandardError nil end end diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb index 1499f72f5d..f4e962f201 100644 --- a/lib/rubygems/commands/yank_command.rb +++ b/lib/rubygems/commands/yank_command.rb @@ -88,7 +88,7 @@ data you will need to change them immediately and yank your gem. def get_version_from_requirements(requirements) requirements.requirements.first[1].version - rescue + rescue StandardError nil end diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 1de9246704..a1fdb00339 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -79,7 +79,7 @@ module Gem def self.find_home Dir.home.dup - rescue + rescue StandardError if Gem.win_platform? File.expand_path File.join(ENV["HOMEDRIVE"] || ENV["SystemDrive"], "/") else @@ -185,7 +185,7 @@ module Gem def self.default_exec_format exec_format = begin RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") - rescue + rescue StandardError "%s" end diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index 02ca000984..e1b4f56fe8 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -74,7 +74,7 @@ class Gem::Ext::Builder build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env) output, status = begin Open3.capture2e(build_env, *command, :chdir => dir) - rescue => error + rescue StandardError => error raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}" end if verbose @@ -174,7 +174,7 @@ EOF verbose { results.join("\n") } write_gem_make_out results.join "\n" - rescue => e + rescue StandardError => e results << e.message build_error(results.join("\n"), $@) end diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb index 022aabf481..fe59151331 100644 --- a/lib/rubygems/ext/cargo_builder.rb +++ b/lib/rubygems/ext/cargo_builder.rb @@ -199,7 +199,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder output, status = begin Open3.capture2e(cargo, "metadata", "--no-deps", "--format-version", "1", :chdir => cargo_dir) - rescue => error + rescue StandardError => error raise Gem::InstallError, "cargo metadata failed #{error.message}" end diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb index 2ef043aff4..61ae306ae5 100644 --- a/lib/rubygems/gem_runner.rb +++ b/lib/rubygems/gem_runner.rb @@ -34,7 +34,7 @@ class Gem::GemRunner begin Gem.load_env_plugins - rescue + rescue StandardError nil end Gem.load_plugins diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb index fdabe8d691..0e5905e8bf 100644 --- a/lib/rubygems/package.rb +++ b/lib/rubygems/package.rb @@ -669,7 +669,7 @@ EOM when "data.tar.gz" then verify_gz entry end - rescue + rescue StandardError warn "Exception while verifying #{@gem.path}" raise end diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index cab2a4b0fe..d33bfd2668 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -126,7 +126,7 @@ class Gem::RemoteFetcher require "fileutils" begin FileUtils.mkdir_p cache_dir - rescue + rescue StandardError nil end unless File.exist? cache_dir @@ -286,7 +286,7 @@ class Gem::RemoteFetcher def cache_update_path(uri, path = nil, update = true) mtime = begin path && File.stat(path).mtime - rescue + rescue StandardError nil end diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb index 78e10a995f..4540ed3cf2 100644 --- a/lib/rubygems/security/signer.rb +++ b/lib/rubygems/security/signer.rb @@ -176,14 +176,14 @@ class Gem::Security::Signer disk_cert_path = File.join(Gem.default_cert_path) disk_cert = begin File.read(disk_cert_path) - rescue + rescue StandardError nil end disk_key_path = File.join(Gem.default_key_path) disk_key = begin OpenSSL::PKey.read(File.read(disk_key_path), @passphrase) - rescue + rescue StandardError nil end diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index c57b173a44..072103e8af 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -137,7 +137,7 @@ class Gem::Source spec = Gem.read_binary local_spec spec = begin Marshal.load(spec) - rescue + rescue StandardError nil end return spec if spec diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index f34741b9c9..7aa76b40f6 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -1520,7 +1520,7 @@ class Gem::Specification < Gem::BasicSpecification else executables end - rescue + rescue StandardError return nil end diff --git a/lib/rubygems/update_suggestion.rb b/lib/rubygems/update_suggestion.rb index c2e81b2374..4cf085fd4c 100644 --- a/lib/rubygems/update_suggestion.rb +++ b/lib/rubygems/update_suggestion.rb @@ -59,7 +59,7 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa return eglible end - rescue # don't block install command on any problem + rescue StandardError # don't block install command on any problem false end diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index 15b5640de4..fe09190cc1 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -85,7 +85,7 @@ module Gem::Util loop do begin Dir.chdir here, &block - rescue + rescue StandardError Errno::EACCES end diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index c3a1454012..c90f581331 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -345,7 +345,7 @@ class Gem::TestCase < Test::Unit::TestCase $LOAD_PATH.map! do |s| expand_path = begin File.realpath(s) - rescue + rescue StandardError File.expand_path(s) end if expand_path != s @@ -1527,7 +1527,7 @@ Also, a list: def self.cert_path(cert_name) if begin Time.at(2**32) - rescue + rescue StandardError 32 end == 32 cert_file = "#{__dir__}/#{cert_name}_cert_32.pem" diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index c86ccc2098..b32a76807b 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -664,7 +664,7 @@ class TestGem < Gem::TestCase gemdir = File.join @tempdir, "a/b/c/gemdir" begin FileUtils.rm_rf File.join(@tempdir, "a") - rescue + rescue StandardError nil end refute File.exist?(File.join(@tempdir, "a")), @@ -681,7 +681,7 @@ class TestGem < Gem::TestCase gemdir = File.join @tempdir, "egd" begin FileUtils.rm_r gemdir - rescue + rescue StandardError nil end refute File.exist?(gemdir), "manually remove #{gemdir}, tests are broken" @@ -702,7 +702,7 @@ class TestGem < Gem::TestCase begin FileUtils.rm_r parent - rescue + rescue StandardError nil end refute File.exist?(parent), "manually remove #{parent}, tests are broken" @@ -1510,7 +1510,7 @@ class TestGem < Gem::TestCase with_plugin("load") { Gem.load_env_plugins } begin assert_equal :loaded, TEST_PLUGIN_LOAD - rescue + rescue StandardError nil end @@ -1520,7 +1520,7 @@ class TestGem < Gem::TestCase with_plugin("standarderror") { Gem.load_env_plugins } begin assert_equal :loaded, TEST_PLUGIN_STANDARDERROR - rescue + rescue StandardError nil end @@ -1530,7 +1530,7 @@ class TestGem < Gem::TestCase with_plugin("exception") { Gem.load_env_plugins } begin assert_equal :loaded, TEST_PLUGIN_EXCEPTION - rescue + rescue StandardError nil end end diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb index 532f8acef0..fd899dbd55 100644 --- a/test/rubygems/test_gem_commands_exec_command.rb +++ b/test/rubygems/test_gem_commands_exec_command.rb @@ -732,7 +732,7 @@ class TestGemCommandsExecCommand < Gem::TestCase begin invoke "gem", "uninstall", "--verbose", "-x", "a" - rescue + rescue StandardError nil end refute_includes @ui.output, "running gem exec with" diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index 3318045ca0..1b6588e854 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -157,7 +157,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase @cmd.execute assert_equal false, File.exist?(formatted_executable) - rescue + rescue StandardError Gem::Installer.exec_format = nil end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 9a71f4eae5..ba30a06080 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1567,7 +1567,7 @@ gem 'other', version installer.install end assert_path_exist so - rescue + rescue StandardError puts "-" * 78 puts File.read File.join(@gemhome, "gems", "a-2", "Makefile") puts "-" * 78 diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 1faf62957a..d512094eff 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -363,7 +363,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== FileUtils.chmod 0555, @a1.cache_dir begin FileUtils.mkdir_p File.join(Gem.user_dir, "cache") - rescue + rescue StandardError nil end FileUtils.chmod 0555, File.join(Gem.user_dir, "cache") diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index eaeddd29c8..c1965487db 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3465,7 +3465,7 @@ Did you mean 'Ruby'? capture_output do Gem::Specification.load(specfile.path) end - rescue => e + rescue StandardError => e name_rexp = Regexp.new(Regexp.escape(specfile.path)) assert e.backtrace.grep(name_rexp).any? end |