[rubygems/rubygems] util/rubocop -A --only Style/ParallelAssignment

https://github.com/rubygems/rubygems/commit/5c88c77873
This commit is contained in:
Hiroshi SHIBATA 2023-03-16 13:07:05 +09:00
Родитель 4bb5ce8188
Коммит 3d4c3f9e4f
21 изменённых файлов: 83 добавлений и 45 удалений

Просмотреть файл

@ -81,7 +81,8 @@ module Gem::Deprecate
# Temporarily turn off warnings. Intended for tests only.
def skip_during
Gem::Deprecate.skip, original = true, Gem::Deprecate.skip
original = Gem::Deprecate.skip
Gem::Deprecate.skip = true
yield
ensure
Gem::Deprecate.skip = original

Просмотреть файл

@ -59,7 +59,8 @@ class Gem::Ext::Builder
verbose = Gem.configuration.really_verbose
begin
rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], nil
rubygems_gemdeps = ENV["RUBYGEMS_GEMDEPS"]
ENV["RUBYGEMS_GEMDEPS"] = nil
if verbose
puts("current directory: #{dir}")
p(command)

Просмотреть файл

@ -89,7 +89,10 @@ class Gem::Platform
end
os, = arch
@cpu, os = nil, cpu if os.nil? # legacy jruby
if os.nil?
@cpu = nil
os = cpu
end # legacy jruby
@os, @version = case os
when /aix(\d+)?/ then [ "aix", $1 ]
@ -106,7 +109,8 @@ class Gem::Platform
when /mingw32/ then [ "mingw32", nil ]
when /mingw-?(\w+)?/ then [ "mingw", $1 ]
when /(mswin\d+)(\_(\d+))?/ then
os, version = $1, $3
os = $1
version = $3
@cpu = "x86" if @cpu.nil? && os =~ /32$/
[os, version]
when /netbsdelf/ then [ "netbsdelf", nil ]

Просмотреть файл

@ -254,7 +254,8 @@ class Gem::RequestSet
end
def install_into(dir, force = true, options = {})
gem_home, ENV["GEM_HOME"] = ENV["GEM_HOME"], dir
gem_home = ENV["GEM_HOME"]
ENV["GEM_HOME"] = dir
existing = force ? [] : specs_in(dir)
existing.delete_if {|s| @always_install.include? s }

Просмотреть файл

@ -75,7 +75,8 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
end
def prefetch_now # :nodoc:
needed, @to_fetch = @to_fetch, []
needed = @to_fetch
@to_fetch = []
needed.sort.each do |name|
versions(name)

Просмотреть файл

@ -366,7 +366,8 @@ class Gem::Version
i = 0
while i <= limit
lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
lhs = lhsegments[i] || 0
rhs = rhsegments[i] || 0
i += 1
next if lhs == rhs

Просмотреть файл

@ -382,8 +382,10 @@ You may need to `bundle install` to install missing gems
end
def with_path_and_rubyopt(path_value, rubyopt_value)
path, ENV["PATH"] = ENV["PATH"], path_value
rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], rubyopt_value
path = ENV["PATH"]
ENV["PATH"] = path_value
rubyopt = ENV["RUBYOPT"]
ENV["RUBYOPT"] = rubyopt_value
yield
ensure
@ -392,7 +394,8 @@ You may need to `bundle install` to install missing gems
end
def with_rubygems_gemdeps(value)
rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], value
rubygems_gemdeps = ENV["RUBYGEMS_GEMDEPS"]
ENV["RUBYGEMS_GEMDEPS"] = value
yield
ensure

Просмотреть файл

@ -120,9 +120,11 @@ class Gem::TestCase < Test::Unit::TestCase
begin
require "tempfile"
captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
captured_stdout = Tempfile.new("out")
captured_stderr = Tempfile.new("err")
orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
orig_stdout = $stdout.dup
orig_stderr = $stderr.dup
$stdout.reopen captured_stdout
$stderr.reopen captured_stderr
@ -1307,7 +1309,8 @@ Also, a list:
end
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, false
old_verbose = $VERBOSE
$VERBOSE = false
yield
ensure
$VERBOSE = old_verbose

Просмотреть файл

@ -1029,7 +1029,8 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_api_version
orig_ruby_version, RbConfig::CONFIG["ruby_version"] = RbConfig::CONFIG["ruby_version"], "1.2.3"
orig_ruby_version = RbConfig::CONFIG["ruby_version"]
RbConfig::CONFIG["ruby_version"] = "1.2.3"
Gem.instance_variable_set :@ruby_api_version, nil

Просмотреть файл

@ -55,7 +55,9 @@ class TestGemCommand < Gem::TestCase
end
def test_self_extra_args
verbose, $VERBOSE, separator = $VERBOSE, nil, $;
verbose = $VERBOSE
$VERBOSE = nil
separator = $;
extra_args = Gem::Command.extra_args
Gem::Command.extra_args = %w[--all]

Просмотреть файл

@ -11,7 +11,8 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
def test_execute
orig_sources = Gem.sources.dup
orig_path, ENV["PATH"] = ENV["PATH"], %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR)
orig_path = ENV["PATH"]
ENV["PATH"] = %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR)
Gem.sources.replace %w[http://gems.example.com]
Gem.configuration["gemcutter_key"] = "blah"

Просмотреть файл

@ -470,7 +470,8 @@ if you believe they were disclosed to a third party.
end
begin
verbose, $VERBOSE = $VERBOSE, nil
verbose = $VERBOSE
$VERBOSE = nil
util_config_file
ensure

Просмотреть файл

@ -203,8 +203,8 @@ gem 'other', version
bin_dir = bin_dir.downcase
end
orig_PATH, ENV["PATH"] =
ENV["PATH"], [ENV["PATH"], bin_dir].join(File::PATH_SEPARATOR)
orig_PATH = ENV["PATH"]
ENV["PATH"] = [ENV["PATH"], bin_dir].join(File::PATH_SEPARATOR)
use_ui @ui do
installer.check_that_user_bin_dir_is_in_path
@ -228,8 +228,8 @@ gem 'other', version
def test_check_that_user_bin_dir_is_in_path_tilde
pend "Tilde is PATH is not supported under MS Windows" if win_platform?
orig_PATH, ENV["PATH"] =
ENV["PATH"], [ENV["PATH"], "~/bin"].join(File::PATH_SEPARATOR)
orig_PATH = ENV["PATH"]
ENV["PATH"] = [ENV["PATH"], "~/bin"].join(File::PATH_SEPARATOR)
installer = setup_base_installer
installer.bin_dir.replace File.join @userhome, "bin"

Просмотреть файл

@ -205,7 +205,8 @@ class TestGemPackage < Gem::Package::TarTestCase
tar.rewind
files, symlinks = [], []
files = []
symlinks = []
Gem::Package::TarReader.new tar do |tar_io|
tar_io.each_entry do |entry|

Просмотреть файл

@ -106,8 +106,8 @@ class TestGemRequest < Gem::TestCase
end
def test_configure_connection_for_https_ssl_ca_cert
ssl_ca_cert, Gem.configuration.ssl_ca_cert =
Gem.configuration.ssl_ca_cert, CA_CERT_FILE
ssl_ca_cert = Gem.configuration.ssl_ca_cert
Gem.configuration.ssl_ca_cert = CA_CERT_FILE
connection = Net::HTTP.new "localhost", 443

Просмотреть файл

@ -120,7 +120,8 @@ class TestGemRequestConnectionPool < Gem::TestCase
end
def test_net_http_args_no_proxy
orig_no_proxy, ENV["no_proxy"] = ENV["no_proxy"], "example"
orig_no_proxy = ENV["no_proxy"]
ENV["no_proxy"] = "example"
pools = Gem::Request::ConnectionPools.new nil, []

Просмотреть файл

@ -245,7 +245,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
end
def test_gem_platforms
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
with_engine_version "ruby", "2.0.0" do
@gda.gem "a", :platforms => :ruby
@ -257,7 +258,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
end
def test_gem_platforms_bundler_ruby
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
with_engine_version "ruby", "2.0.0" do
set = Gem::RequestSet.new
@ -319,7 +321,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
end
def test_gem_platforms_maglev
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
with_engine_version "maglev", "1.0.0" do
set = Gem::RequestSet.new
@ -355,7 +358,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
end
def test_gem_platforms_multiple
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
with_engine_version "ruby", "2.0.0" do
@gda.gem "a", :platforms => [:mswin, :jruby]
@ -367,7 +371,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
end
def test_gem_platforms_platform
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
with_engine_version "ruby", "2.0.0" do
@gda.gem "a", :platforms => :jruby, :platform => :ruby
@ -694,7 +699,8 @@ end
end
def test_platform_multiple
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
gda = @GDA.new @set, nil
@ -720,7 +726,8 @@ end
end
def test_platform_ruby
win_platform, Gem.win_platform = Gem.win_platform?, false
win_platform = Gem.win_platform?
Gem.win_platform = false
@gda.platform :ruby do
@gda.gem "a"

Просмотреть файл

@ -1683,8 +1683,8 @@ dependencies: []
end
def test_extension_dir
enable_shared, RbConfig::CONFIG["ENABLE_SHARED"] =
RbConfig::CONFIG["ENABLE_SHARED"], "no"
enable_shared = RbConfig::CONFIG["ENABLE_SHARED"]
RbConfig::CONFIG["ENABLE_SHARED"] = "no"
ext_spec
@ -1700,8 +1700,8 @@ dependencies: []
end
def test_extension_dir_override
enable_shared, RbConfig::CONFIG["ENABLE_SHARED"] =
RbConfig::CONFIG["ENABLE_SHARED"], "no"
enable_shared = RbConfig::CONFIG["ENABLE_SHARED"]
RbConfig::CONFIG["ENABLE_SHARED"] = "no"
class << Gem
alias_method :orig_default_ext_dir_for, :default_ext_dir_for

Просмотреть файл

@ -28,9 +28,12 @@ class TestUpdateSuggestion < Gem::TestCase
reset_last_update_check: true,
cmd:
)
original_config, Gem.configuration[:prevent_update_suggestion] = Gem.configuration[:prevent_update_suggestion], nil
original_env, ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"], nil
original_disable, Gem.disable_system_update_message = Gem.disable_system_update_message, nil
original_config = Gem.configuration[:prevent_update_suggestion]
Gem.configuration[:prevent_update_suggestion] = nil
original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = nil
original_disable = Gem.disable_system_update_message
Gem.disable_system_update_message = nil
Gem.configuration.last_update_check = 0 if reset_last_update_check
Gem.ui.stub :tty?, tty do
@ -143,7 +146,8 @@ class TestUpdateSuggestion < Gem::TestCase
def test_eglible_for_update_prevent_config
with_eglible_environment(cmd: @cmd) do
begin
original_config, Gem.configuration[:prevent_update_suggestion] = Gem.configuration[:prevent_update_suggestion], true
original_config = Gem.configuration[:prevent_update_suggestion]
Gem.configuration[:prevent_update_suggestion] = true
refute @cmd.eglible_for_update?
ensure
Gem.configuration[:prevent_update_suggestion] = original_config
@ -154,7 +158,8 @@ class TestUpdateSuggestion < Gem::TestCase
def test_eglible_for_update_prevent_env
with_eglible_environment(cmd: @cmd) do
begin
original_env, ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"], "yes"
original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "yes"
refute @cmd.eglible_for_update?
ensure
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
@ -177,7 +182,8 @@ class TestUpdateSuggestion < Gem::TestCase
def test_eglible_for_update_disabled_update
with_eglible_environment(cmd: @cmd) do
begin
original_disable, Gem.disable_system_update_message = Gem.disable_system_update_message, "disabled"
original_disable = Gem.disable_system_update_message
Gem.disable_system_update_message = "disabled"
refute @cmd.eglible_for_update?
ensure
Gem.disable_system_update_message = original_disable

Просмотреть файл

@ -268,7 +268,8 @@ class TestGemVersion < Gem::TestCase
# Assert that two versions are eql?. Checks both directions.
def assert_version_eql(first, second)
first, second = v(first), v(second)
first = v(first)
second = v(second)
assert first.eql?(second), "#{first} is eql? #{second}"
assert second.eql?(first), "#{second} is eql? #{first}"
end
@ -289,7 +290,8 @@ class TestGemVersion < Gem::TestCase
# directions.
def refute_version_eql(first, second)
first, second = v(first), v(second)
first = v(first)
second = v(second)
refute first.eql?(second), "#{first} is NOT eql? #{second}"
refute second.eql?(first), "#{second} is NOT eql? #{first}"
end

Просмотреть файл

@ -329,7 +329,8 @@ class Gem::TestCase::SpecFetcherSetup
Gem::Specification.reset
begin
gem_repo, @test.gem_repo = @test.gem_repo, @repository
gem_repo = @test.gem_repo
@test.gem_repo = @repository
@test.uri = URI @repository
@test.util_setup_spec_fetcher(*@downloaded)