summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2023-03-16 13:48:03 +0900
committerHiroshi SHIBATA <[email protected]>2023-03-17 18:50:55 +0900
commit70164eec0f48a691dd039f55ac897036aa32e5cf (patch)
treee991dceeb7aa2d730d60ae8ca8ce512fa7517823 /lib/rubygems
parentfef0313ec79beab2383e30062803a0f21b198b21 (diff)
[rubygems/rubygems] util/rubocop -A --only Style/RescueModifier
https://github.com/rubygems/rubygems/commit/b490379eab
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/commands/check_command.rb6
-rw-r--r--lib/rubygems/commands/specification_command.rb6
-rw-r--r--lib/rubygems/defaults.rb6
-rw-r--r--lib/rubygems/gem_runner.rb6
-rw-r--r--lib/rubygems/remote_fetcher.rb12
-rw-r--r--lib/rubygems/security/signer.rb12
-rw-r--r--lib/rubygems/source.rb6
-rw-r--r--lib/rubygems/util.rb6
8 files changed, 50 insertions, 10 deletions
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index 4d1f8782b1..e3c288d659 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -40,7 +40,11 @@ class Gem::Commands::CheckCommand < Gem::Command
def check_gems
say "Checking gems..."
say
- gems = get_all_gem_names rescue []
+ gems = begin
+ get_all_gem_names
+ rescue
+ []
+ end
Gem::Validator.new.alien(gems).sort.each do |key, val|
unless val.empty?
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 5cdf5966d2..6025660498 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -106,7 +106,11 @@ Specific fields in the specification can be extracted in YAML format:
if local?
if File.exist? gem
- specs << Gem::Package.new(gem).spec rescue nil
+ begin
+ specs << Gem::Package.new(gem).spec
+ rescue
+ nil
+ end
end
if specs.empty?
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index b186375f69..1de9246704 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -183,7 +183,11 @@ module Gem
# Deduce Ruby's --program-prefix and --program-suffix from its install name
def self.default_exec_format
- exec_format = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") rescue "%s"
+ exec_format = begin
+ RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s")
+ rescue
+ "%s"
+ end
unless exec_format.include?("%s")
raise Gem::Exception,
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
index c63c177ed2..2ef043aff4 100644
--- a/lib/rubygems/gem_runner.rb
+++ b/lib/rubygems/gem_runner.rb
@@ -32,7 +32,11 @@ class Gem::GemRunner
do_configuration args
- Gem.load_env_plugins rescue nil
+ begin
+ Gem.load_env_plugins
+ rescue
+ nil
+ end
Gem.load_plugins
cmd = @command_manager_class.instance
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 5a0898f084..cab2a4b0fe 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -124,7 +124,11 @@ class Gem::RemoteFetcher
local_gem_path = File.join cache_dir, gem_file_name
require "fileutils"
- FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
+ begin
+ FileUtils.mkdir_p cache_dir
+ rescue
+ nil
+ end unless File.exist? cache_dir
source_uri = Gem::Uri.new(source_uri)
@@ -280,7 +284,11 @@ class Gem::RemoteFetcher
# passes the data.
def cache_update_path(uri, path = nil, update = true)
- mtime = path && File.stat(path).mtime rescue nil
+ mtime = begin
+ path && File.stat(path).mtime
+ rescue
+ nil
+ end
data = fetch_path(uri, mtime)
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index 93b466a76d..78e10a995f 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -174,10 +174,18 @@ class Gem::Security::Signer
old_cert = @cert_chain.last
disk_cert_path = File.join(Gem.default_cert_path)
- disk_cert = File.read(disk_cert_path) rescue nil
+ disk_cert = begin
+ File.read(disk_cert_path)
+ rescue
+ nil
+ end
disk_key_path = File.join(Gem.default_key_path)
- disk_key = OpenSSL::PKey.read(File.read(disk_key_path), @passphrase) rescue nil
+ disk_key = begin
+ OpenSSL::PKey.read(File.read(disk_key_path), @passphrase)
+ rescue
+ nil
+ end
return unless disk_key
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb
index 74ea2c61b3..c57b173a44 100644
--- a/lib/rubygems/source.rb
+++ b/lib/rubygems/source.rb
@@ -135,7 +135,11 @@ class Gem::Source
if File.exist? local_spec
spec = Gem.read_binary local_spec
- spec = Marshal.load(spec) rescue nil
+ spec = begin
+ Marshal.load(spec)
+ rescue
+ nil
+ end
return spec if spec
end
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index b19e22aef9..15b5640de4 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -83,7 +83,11 @@ module Gem::Util
here = File.expand_path directory
loop do
- Dir.chdir here, &block rescue Errno::EACCES
+ begin
+ Dir.chdir here, &block
+ rescue
+ Errno::EACCES
+ end
new_here = File.expand_path("..", here)
return if new_here == here # toplevel