[rubygems/rubygems] util/rubocop -A --only Lint/UnusedBlockArgument

https://github.com/rubygems/rubygems/commit/d8efd919db
This commit is contained in:
Hiroshi SHIBATA 2023-03-16 10:46:45 +09:00
Родитель 7ab4ede4f5
Коммит 05208c3875
33 изменённых файлов: 77 добавлений и 77 удалений

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

@ -146,7 +146,7 @@ class Gem::AvailableSet
end
def remove_installed!(dep)
@set.reject! do |t|
@set.reject! do |_t|
# already locally installed
Gem::Specification.any? do |installed_spec|
dep.name == installed_spec.name &&

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

@ -583,12 +583,12 @@ class Gem::Command
# Add the options common to all commands.
add_common_option("-h", "--help",
"Get help on this command") do |value, options|
"Get help on this command") do |_value, options|
options[:help] = true
end
add_common_option("-V", "--[no-]verbose",
"Set the verbose level of output") do |value, options|
"Set the verbose level of output") do |value, _options|
# Set us to "really verbose" so the progress meter works
if Gem.configuration.verbose && value
Gem.configuration.verbose = 1
@ -597,12 +597,12 @@ class Gem::Command
end
end
add_common_option("-q", "--quiet", "Silence command progress meter") do |value, options|
add_common_option("-q", "--quiet", "Silence command progress meter") do |_value, _options|
Gem.configuration.verbose = false
end
add_common_option("--silent",
"Silence RubyGems output") do |value, options|
"Silence RubyGems output") do |_value, options|
options[:silent] = true
end

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

@ -11,11 +11,11 @@ class Gem::Commands::BuildCommand < Gem::Command
add_platform_option
add_option "--force", "skip validation of the spec" do |value, options|
add_option "--force", "skip validation of the spec" do |_value, options|
options[:force] = true
end
add_option "--strict", "consider warnings as errors when validating the spec" do |value, options|
add_option "--strict", "consider warnings as errors when validating the spec" do |_value, options|
options[:strict] = true
end

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

@ -11,12 +11,12 @@ class Gem::Commands::CleanupCommand < Gem::Command
:check_dev => true
add_option("-n", "-d", "--dry-run",
"Do not uninstall gems") do |value, options|
"Do not uninstall gems") do |_value, options|
options[:dryrun] = true
end
add_option(:Deprecated, "--dryrun",
"Do not uninstall gems") do |value, options|
"Do not uninstall gems") do |_value, options|
options[:dryrun] = true
end
deprecate_option("--dryrun", extra_msg: "Use --dry-run instead")

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

@ -22,7 +22,7 @@ class Gem::Commands::ExecCommand < Gem::Command
add_option(:"Install/Update", "--conservative",
"Prefer the most recent installed version, ",
"rather than the latest version overall") do |value, options|
"rather than the latest version overall") do |_value, options|
options[:conservative] = true
end
end

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

@ -20,19 +20,19 @@ class Gem::Commands::SpecificationCommand < Gem::Command
add_prerelease_option
add_option("--all", "Output specifications for all versions of",
"the gem") do |value, options|
"the gem") do |_value, options|
options[:all] = true
end
add_option("--ruby", "Output ruby format") do |value, options|
add_option("--ruby", "Output ruby format") do |_value, options|
options[:format] = :ruby
end
add_option("--yaml", "Output YAML format") do |value, options|
add_option("--yaml", "Output YAML format") do |_value, options|
options[:format] = :yaml
end
add_option("--marshal", "Output Marshal format") do |value, options|
add_option("--marshal", "Output Marshal format") do |_value, options|
options[:format] = :marshal
end

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

@ -79,7 +79,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
add_option("--vendor",
"Uninstall gem from the vendor directory.",
"Only for use by gem repackagers.") do |value, options|
"Only for use by gem repackagers.") do |_value, options|
unless Gem.vendor_dir
raise Gem::OptionParser::InvalidOption.new "your platform is not supported"
end

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

@ -28,7 +28,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
options[:target] = value
end
add_option("--spec", "unpack the gem specification") do |value, options|
add_option("--spec", "unpack the gem specification") do |_value, options|
options[:spec] = true
end

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

@ -300,7 +300,7 @@ command to remove old versions.
def which_to_update(highest_installed_gems, gem_names)
result = []
highest_installed_gems.each do |l_name, l_spec|
highest_installed_gems.each do |_l_name, l_spec|
next if !gem_names.empty? &&
gem_names.none? {|name| name == l_spec.name }

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

@ -137,7 +137,7 @@ module Gem::GemcutterUtilities
request.body = URI.encode_www_form({ :api_key => api_key }.merge(update_scope_params))
end
with_response response do |resp|
with_response response do |_resp|
say "Added #{scope} scope to the existing API key"
end
end

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

@ -49,7 +49,7 @@ module Gem::InstallUpdateOptions
add_option(:"Install/Update", "--vendor",
"Install gem into the vendor directory.",
"Only for use by gem repackagers.") do |value, options|
"Only for use by gem repackagers.") do |_value, options|
unless Gem.vendor_dir
raise Gem::OptionParser::InvalidOption.new "your platform is not supported"
end
@ -59,7 +59,7 @@ module Gem::InstallUpdateOptions
end
add_option(:"Install/Update", "-N", "--no-document",
"Disable documentation generation") do |value, options|
"Disable documentation generation") do |_value, options|
options[:document] = []
end
@ -103,21 +103,21 @@ module Gem::InstallUpdateOptions
add_option(:"Install/Update", "--development",
"Install additional development",
"dependencies") do |value, options|
"dependencies") do |_value, options|
options[:development] = true
options[:dev_shallow] = true
end
add_option(:"Install/Update", "--development-all",
"Install development dependencies for all",
"gems (including dev deps themselves)") do |value, options|
"gems (including dev deps themselves)") do |_value, options|
options[:development] = true
options[:dev_shallow] = false
end
add_option(:"Install/Update", "--conservative",
"Don't attempt to upgrade gems already",
"meeting version requirement") do |value, options|
"meeting version requirement") do |_value, options|
options[:conservative] = true
options[:minimal_deps] = true
end
@ -135,7 +135,7 @@ module Gem::InstallUpdateOptions
add_option(:"Install/Update", "-g", "--file [FILE]",
"Read from a gem dependencies API file and",
"install the listed gems") do |v,o|
"install the listed gems") do |v,_o|
v = Gem::GEM_DEP_FILES.find do |file|
File.exist? file
end unless v
@ -153,29 +153,29 @@ module Gem::InstallUpdateOptions
add_option(:"Install/Update", "--without GROUPS", Array,
"Omit the named groups (comma separated)",
"when installing from a gem dependencies",
"file") do |v,o|
"file") do |v,_o|
options[:without_groups].concat v.map {|without| without.intern }
end
add_option(:"Install/Update", "--default",
"Add the gem's full specification to",
"specifications/default and extract only its bin") do |v,o|
"specifications/default and extract only its bin") do |v,_o|
options[:install_as_default] = v
end
add_option(:"Install/Update", "--explain",
"Rather than install the gems, indicate which would",
"be installed") do |v,o|
"be installed") do |v,_o|
options[:explain] = v
end
add_option(:"Install/Update", "--[no-]lock",
"Create a lock file (when used with -g/--file)") do |v,o|
"Create a lock file (when used with -g/--file)") do |v,_o|
options[:lock] = v
end
add_option(:"Install/Update", "--[no-]suggestions",
"Suggest alternates when gems are not found") do |v,o|
"Suggest alternates when gems are not found") do |v,_o|
options[:suggest_alternate] = v
end
end

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

@ -39,17 +39,17 @@ module Gem::LocalRemoteOptions
def add_local_remote_options
add_option(:"Local/Remote", "-l", "--local",
"Restrict operations to the LOCAL domain") do |value, options|
"Restrict operations to the LOCAL domain") do |_value, options|
options[:domain] = :local
end
add_option(:"Local/Remote", "-r", "--remote",
"Restrict operations to the REMOTE domain") do |value, options|
"Restrict operations to the REMOTE domain") do |_value, options|
options[:domain] = :remote
end
add_option(:"Local/Remote", "-b", "--both",
"Allow LOCAL and REMOTE operations") do |value, options|
"Allow LOCAL and REMOTE operations") do |_value, options|
options[:domain] = :both
end
@ -67,7 +67,7 @@ module Gem::LocalRemoteOptions
add_option(:"Local/Remote", "-B", "--bulk-threshold COUNT",
"Threshold for switching to bulk",
"synchronization (default #{Gem.configuration.bulk_threshold})") do
|value, options|
|value, _options|
Gem.configuration.bulk_threshold = value.to_i
end
end
@ -77,7 +77,7 @@ module Gem::LocalRemoteOptions
def add_clear_sources_option
add_option(:"Local/Remote", "--clear-sources",
"Clear the gem sources") do |value, options|
"Clear the gem sources") do |_value, options|
Gem.sources = nil
options[:sources_cleared] = true
end
@ -119,7 +119,7 @@ module Gem::LocalRemoteOptions
def add_update_sources_option
add_option(:Deprecated, "-u", "--[no-]update-sources",
"Update local source cache") do |value, options|
"Update local source cache") do |value, _options|
Gem.configuration.update_sources = value
end
end

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

@ -691,7 +691,7 @@ EOM
"package content (data.tar.gz) is missing", @gem
end
if (duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first)) && duplicates.any?
if (duplicates = @files.group_by {|f| f }.select {|_k,v| v.size > 1 }.map(&:first)) && duplicates.any?
raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(', ')})"
end
end

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

@ -17,7 +17,7 @@ module Gem::QueryUtils
options[:installed] = value
end
add_option("-I", "Equivalent to --no-installed") do |value, options|
add_option("-I", "Equivalent to --no-installed") do |_value, options|
options[:installed] = false
end
@ -197,7 +197,7 @@ module Gem::QueryUtils
end
def output_versions(output, versions)
versions.each do |gem_name, matching_tuples|
versions.each do |_gem_name, matching_tuples|
matching_tuples = matching_tuples.sort_by {|n,_| n.version }.reverse
platforms = Hash.new {|h,version| h[version] = [] }

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

@ -225,7 +225,7 @@ class Gem::Security::Policy
trust_dir = opt[:trust_dir]
time = Time.now
_, signer_digests = digests.find do |algorithm, file_digests|
_, signer_digests = digests.find do |_algorithm, file_digests|
file_digests.values.first.name == Gem::Security::DIGEST_NAME
end

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

@ -113,7 +113,7 @@ class Gem::Source::Local < Gem::Source
def download(spec, cache_dir = nil) # :nodoc:
load_specs :complete
@specs.each do |name, data|
@specs.each do |_name, data|
return data[0] if data[1].spec == spec
end

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

@ -193,10 +193,10 @@ class Gem::SpecFetcher
matches = if matches.empty? && type != :prerelease
suggest_gems_from_name gem_name, :prerelease
else
matches.uniq.sort_by {|name, dist| dist }
matches.uniq.sort_by {|_name, dist| dist }
end
matches.map {|name, dist| name }.uniq.first(num_results)
matches.map {|name, _dist| name }.uniq.first(num_results)
end
##

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

@ -175,7 +175,7 @@ class Gem::Specification < Gem::BasicSpecification
end
@@attributes = @@default_value.keys.sort_by {|s| s.to_s }
@@array_attributes = @@default_value.reject {|k,v| v != [] }.keys
@@array_attributes = @@default_value.reject {|_k,v| v != [] }.keys
@@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
@@default_value[k].nil?
end
@ -1072,7 +1072,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_in_unresolved_tree(path)
unresolved_specs.each do |spec|
spec.traverse do |from_spec, dep, to_spec, trail|
spec.traverse do |_from_spec, _dep, to_spec, trail|
if to_spec.has_conflicts? || to_spec.conficts_when_loaded_with?(trail)
:next
else
@ -2376,7 +2376,7 @@ class Gem::Specification < Gem::BasicSpecification
# True if this gem has the same attributes as +other+.
def same_attributes?(spec)
@@attributes.all? {|name, default| self.send(name) == spec.send(name) }
@@attributes.all? {|name, _default| self.send(name) == spec.send(name) }
end
private :same_attributes?

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

@ -341,7 +341,7 @@ class Gem::Uninstaller
s.name == spec.name && s.full_name != spec.full_name
end
spec.dependent_gems(@check_dev).each do |dep_spec, dep, satlist|
spec.dependent_gems(@check_dev).each do |dep_spec, dep, _satlist|
unless siblings.any? {|s| s.satisfies_requirement? dep }
msg << "#{dep_spec.name}-#{dep_spec.version} depends on #{dep}"
end

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

@ -87,7 +87,7 @@ class Gem::Validator
good, gone, unreadable = nil, nil, nil, nil
File.open gem_path, Gem.binary_mode do |file|
File.open gem_path, Gem.binary_mode do |_file|
package = Gem::Package.new gem_path
good, gone = package.contents.partition do |file_name|

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

@ -1740,7 +1740,7 @@ class TestGem < Gem::TestCase
#
# FIXME what does this solve precisely? -ebh
#
@additional.each do |dir|
@additional.each do |_dir|
Gem.ensure_gem_subdirectories @gemhome
end
end

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

@ -15,7 +15,7 @@ class TestGemCommand < Gem::TestCase
@common_options = Gem::Command.common_options.dup
Gem::Command.common_options.clear
Gem::Command.common_options << [
["-x", "--exe", "Execute"], lambda do |*a|
["-x", "--exe", "Execute"], lambda do |*_a|
@xopt = true
end
]
@ -151,7 +151,7 @@ class TestGemCommand < Gem::TestCase
done = false
use_ui @ui do
@cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options|
@cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |_value, options|
options[:help] = true
done = true
end
@ -174,7 +174,7 @@ class TestGemCommand < Gem::TestCase
end
def test_invoke_with_options
@cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options|
@cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |_value, options|
options[:help] = true
end
@ -202,13 +202,13 @@ class TestGemCommand < Gem::TestCase
end
def test_option_recognition
@cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options|
@cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |_value, options|
options[:help] = true
end
@cmd.add_option("-f", "--file FILE", "File option") do |value, options|
@cmd.add_option("-f", "--file FILE", "File option") do |_value, options|
options[:help] = true
end
@cmd.add_option("--silent", "Silence RubyGems output") do |value, options|
@cmd.add_option("--silent", "Silence RubyGems output") do |_value, options|
options[:silent] = true
end
assert @cmd.handles?(["-x"])
@ -236,7 +236,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in Rubyg
def initialize
super("test", "Gem::Command instance for testing")
add_option("-t", "--test", "Test command") do |value, options|
add_option("-t", "--test", "Test command") do |_value, options|
options[:test] = true
end
@ -265,7 +265,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in futur
def initialize
super("test", "Gem::Command instance for testing")
add_option("-t", "--test", "Test command") do |value, options|
add_option("-t", "--test", "Test command") do |_value, options|
options[:test] = true
end
@ -294,7 +294,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in Rubyg
def initialize
super("test", "Gem::Command instance for testing")
add_option("-t", "--test", "Test command") do |value, options|
add_option("-t", "--test", "Test command") do |_value, options|
options[:test] = true
end
@ -323,7 +323,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in futur
def initialize
super("test", "Gem::Command instance for testing")
add_option("-t", "--test", "Test command") do |value, options|
add_option("-t", "--test", "Test command") do |_value, options|
options[:test] = true
end

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

@ -63,7 +63,7 @@ class TestGemCommandsHelpCommand < Gem::TestCase
def test_gem_help_commands_omits_deprecated_commands
mgr = Gem::CommandManager.new
util_gem "commands" do |out, err|
util_gem "commands" do |out, _err|
deprecated_commands = mgr.command_names.select {|cmd| mgr[cmd].deprecated? }
deprecated_commands.each do |cmd|
refute_match(/\A\s+#{cmd}\s+\S+\z/, out)

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

@ -561,7 +561,7 @@ class TestGemDependencyInstaller < Gem::TestCase
done_installing_called = false
Gem.done_installing do |dep_installer, specs|
Gem.done_installing do |dep_installer, _specs|
done_installing_called = true
assert_empty dep_installer.document
end

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

@ -91,7 +91,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
create_temp_mkrf_file("task :default do abort 'fail' end")
output = []
build_rake_in(false) do |rake|
build_rake_in(false) do |_rake|
error = assert_raise Gem::InstallError do
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output, [], nil, @ext
end

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

@ -1025,7 +1025,7 @@ gem 'other', version
@gem = setup_base_gem
# build old version that has a bin file
installer = util_setup_gem do |spec|
installer = util_setup_gem do |_spec|
File.open File.join("bin", "executable"), "w" do |f|
f.puts "require 'code'"
end

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

@ -77,7 +77,7 @@ class TestGemPackageTarReader < Gem::Package::TarTestCase
io = TempIO.new tar
Gem::Package::TarReader.new io do |tar_reader|
tar_reader.seek "nonexistent" do |entry|
tar_reader.seek "nonexistent" do |_entry|
flunk "entry missing but entry-found block was run"
end

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

@ -1142,7 +1142,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:SSLVerifyClient => nil,
:SSLCertName => nil,
}.merge(config))
server.mount_proc("/yaml") do |req, res|
server.mount_proc("/yaml") do |_req, res|
res.body = "--- true\n"
end
server.mount_proc("/insecure_redirect") do |req, res|
@ -1179,7 +1179,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:Logger => null_logger,
:AccessLog => null_logger
)
s.mount_proc("/kill") {|req, res| s.shutdown }
s.mount_proc("/kill") {|_req, _res| s.shutdown }
s.mount_proc("/yaml") do |req, res|
if req["X-Captain"]
res.body = req["X-Captain"]
@ -1193,7 +1193,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
res["Content-Type"] = "text/html"
end
end
s.mount_proc("/yaml.Z") do |req, res|
s.mount_proc("/yaml.Z") do |_req, res|
if @enable_zip
res.body = Zlib::Deflate.deflate(data)
res["Content-Type"] = "text/plain"

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

@ -248,7 +248,7 @@ class TestGemRequest < Gem::TestCase
def test_fetch_head
uri = Gem::Uri.new(URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}")
response = util_stub_net_http(:body => "", :code => 200) do |conn|
response = util_stub_net_http(:body => "", :code => 200) do |_conn|
@request = make_request(uri, Net::HTTP::Get, nil, nil)
@request.fetch
end

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

@ -45,7 +45,7 @@ class TestGemRequestSet < Gem::TestCase
done_installing_ran = false
Gem.done_installing do |installer, specs|
Gem.done_installing do |_installer, _specs|
done_installing_ran = true
end
@ -56,7 +56,7 @@ class TestGemRequestSet < Gem::TestCase
io.puts 'gem "a"'
io.flush
result = rs.install_from_gemdeps :gemdeps => io.path do |req, installer|
result = rs.install_from_gemdeps :gemdeps => io.path do |req, _installer|
installed << req.full_name
end
@ -114,7 +114,7 @@ Gems to install:
:install_dir => "#{@gemhome}2",
}
rs.install_from_gemdeps options do |req, installer|
rs.install_from_gemdeps options do |req, _installer|
installed << req.full_name
end
@ -172,7 +172,7 @@ DEPENDENCIES
io.puts 'gem "b"'
end
rs.install_from_gemdeps :gemdeps => "gem.deps.rb" do |req, installer|
rs.install_from_gemdeps :gemdeps => "gem.deps.rb" do |req, _installer|
installed << req.full_name
end
@ -226,7 +226,7 @@ end
io.puts("gemspec")
end
rs.install_from_gemdeps :gemdeps => "Gemfile" do |req, installer|
rs.install_from_gemdeps :gemdeps => "Gemfile" do |req, _installer|
installed << req.full_name
end
@ -251,7 +251,7 @@ ruby "0"
io.flush
rs.install_from_gemdeps :gemdeps => io.path do |req, installer|
rs.install_from_gemdeps :gemdeps => io.path do |req, _installer|
installed << req.full_name
end
end

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

@ -115,7 +115,7 @@ class TestGemSilentUI < Gem::TestCase
end
def test_new_without_dev_null
File.stub(:open, ->(path, mode) { raise Errno::ENOTCAPABLE if path == IO::NULL }) do
File.stub(:open, ->(path, _mode) { raise Errno::ENOTCAPABLE if path == IO::NULL }) do
Gem::SilentUI.new
end
end

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

@ -2930,7 +2930,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
{ b: Gem::Dependency.new("x","1") }
end
specification.define_singleton_method(:find_all_by_name) do |dep_name|
specification.define_singleton_method(:find_all_by_name) do |_dep_name|
[]
end
@ -2957,7 +2957,7 @@ Please report a bug if this causes problems.
{ b: Gem::Dependency.new("x","1") }
end
specification.define_singleton_method(:find_all_by_name) do |dep_name|
specification.define_singleton_method(:find_all_by_name) do |_dep_name|
[
specification.new {|s| s.name = "z", s.version = Gem::Version.new("1") },
specification.new {|s| s.name = "z", s.version = Gem::Version.new("2") },

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

@ -425,7 +425,7 @@ class TestGemRequire < Gem::TestCase
times_called = 0
Kernel.stub(:gem, ->(name, requirement) { times_called += 1 }) do
Kernel.stub(:gem, ->(_name, _requirement) { times_called += 1 }) do
refute_require "default/gem"
end