[rubygems/rubygems] util/rubocop -A --only Style/RescueModifier
https://github.com/rubygems/rubygems/commit/b490379eab
This commit is contained in:
parent
fef0313ec7
commit
70164eec0f
@ -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?
|
||||
|
@ -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?
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -343,7 +343,11 @@ class Gem::TestCase < Test::Unit::TestCase
|
||||
|
||||
@orig_LOAD_PATH = $LOAD_PATH.dup
|
||||
$LOAD_PATH.map! do |s|
|
||||
expand_path = File.realpath(s) rescue File.expand_path(s)
|
||||
expand_path = begin
|
||||
File.realpath(s)
|
||||
rescue
|
||||
File.expand_path(s)
|
||||
end
|
||||
if expand_path != s
|
||||
expand_path.tap(&Gem::UNTAINT)
|
||||
if s.instance_variable_defined?(:@gem_prelude_index)
|
||||
@ -1521,7 +1525,11 @@ Also, a list:
|
||||
# <tt>test/rubygems/</tt>.
|
||||
|
||||
def self.cert_path(cert_name)
|
||||
if (Time.at(2**32) rescue 32) == 32
|
||||
if begin
|
||||
Time.at(2**32)
|
||||
rescue
|
||||
32
|
||||
end == 32
|
||||
cert_file = "#{__dir__}/#{cert_name}_cert_32.pem"
|
||||
|
||||
return cert_file if File.exist? cert_file
|
||||
|
@ -662,7 +662,11 @@ class TestGem < Gem::TestCase
|
||||
|
||||
def test_self_ensure_gem_directories_missing_parents
|
||||
gemdir = File.join @tempdir, "a/b/c/gemdir"
|
||||
FileUtils.rm_rf File.join(@tempdir, "a") rescue nil
|
||||
begin
|
||||
FileUtils.rm_rf File.join(@tempdir, "a")
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
refute File.exist?(File.join(@tempdir, "a")),
|
||||
"manually remove #{File.join @tempdir, "a"}, tests are broken"
|
||||
Gem.use_paths gemdir
|
||||
@ -675,7 +679,11 @@ class TestGem < Gem::TestCase
|
||||
unless win_platform? || Process.uid.zero? # only for FS that support write protection
|
||||
def test_self_ensure_gem_directories_write_protected
|
||||
gemdir = File.join @tempdir, "egd"
|
||||
FileUtils.rm_r gemdir rescue nil
|
||||
begin
|
||||
FileUtils.rm_r gemdir
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
refute File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
|
||||
FileUtils.mkdir_p gemdir
|
||||
FileUtils.chmod 0400, gemdir
|
||||
@ -692,7 +700,11 @@ class TestGem < Gem::TestCase
|
||||
parent = File.join(@tempdir, "egd")
|
||||
gemdir = "#{parent}/a/b/c"
|
||||
|
||||
FileUtils.rm_r parent rescue nil
|
||||
begin
|
||||
FileUtils.rm_r parent
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
refute File.exist?(parent), "manually remove #{parent}, tests are broken"
|
||||
FileUtils.mkdir_p parent
|
||||
FileUtils.chmod 0400, parent
|
||||
@ -1496,19 +1508,31 @@ class TestGem < Gem::TestCase
|
||||
|
||||
def test_load_env_plugins
|
||||
with_plugin("load") { Gem.load_env_plugins }
|
||||
assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil
|
||||
begin
|
||||
assert_equal :loaded, TEST_PLUGIN_LOAD
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
util_remove_interrupt_command
|
||||
|
||||
# Should attempt to cause a StandardError
|
||||
with_plugin("standarderror") { Gem.load_env_plugins }
|
||||
assert_equal :loaded, TEST_PLUGIN_STANDARDERROR rescue nil
|
||||
begin
|
||||
assert_equal :loaded, TEST_PLUGIN_STANDARDERROR
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
util_remove_interrupt_command
|
||||
|
||||
# Should attempt to cause an Exception
|
||||
with_plugin("exception") { Gem.load_env_plugins }
|
||||
assert_equal :loaded, TEST_PLUGIN_EXCEPTION rescue nil
|
||||
begin
|
||||
assert_equal :loaded, TEST_PLUGIN_EXCEPTION
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def test_gem_path_ordering
|
||||
|
@ -730,7 +730,11 @@ class TestGemCommandsExecCommand < Gem::TestCase
|
||||
assert_includes @ui.output, "a (2)\n"
|
||||
assert_includes @ui.output, "b (2)\n"
|
||||
|
||||
invoke "gem", "uninstall", "--verbose", "-x", "a" rescue nil
|
||||
begin
|
||||
invoke "gem", "uninstall", "--verbose", "-x", "a"
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
refute_includes @ui.output, "running gem exec with"
|
||||
assert_includes @ui.output, "Successfully uninstalled a-2\n"
|
||||
|
||||
|
@ -361,7 +361,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
||||
local_path = File.join @tempdir, @a1.file_name
|
||||
inst = nil
|
||||
FileUtils.chmod 0555, @a1.cache_dir
|
||||
FileUtils.mkdir_p File.join(Gem.user_dir, "cache") rescue nil
|
||||
begin
|
||||
FileUtils.mkdir_p File.join(Gem.user_dir, "cache")
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
FileUtils.chmod 0555, File.join(Gem.user_dir, "cache")
|
||||
|
||||
Dir.chdir @tempdir do
|
||||
|
Loading…
x
Reference in New Issue
Block a user