summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-04-07 09:15:17 +0900
committergit <svn-admin@ruby-lang.org>2023-04-07 05:13:05 +0000
commit250e97c0fba48d1f87ccecb1b1e1b4bd2a30c388 (patch)
treeb9018bb2916c2e007b7f57981295e4c4f0fd5adc
parent84ce6fc87347c15cc81939de2d1872984711a4ed (diff)
[rubygems/rubygems] util/rubocop -A --only Style/FormatString
https://github.com/rubygems/rubygems/commit/132a56569d
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/help_command.rb2
-rw-r--r--lib/rubygems/dependency.rb6
-rw-r--r--lib/rubygems/dependency_list.rb2
-rw-r--r--lib/rubygems/deprecate.rb2
-rw-r--r--lib/rubygems/errors.rb6
-rw-r--r--lib/rubygems/ext/builder.rb6
-rw-r--r--lib/rubygems/package.rb6
-rw-r--r--lib/rubygems/package/tar_header.rb2
-rw-r--r--lib/rubygems/resolver/activation_request.rb4
-rw-r--r--lib/rubygems/resolver/conflict.rb12
-rw-r--r--lib/rubygems/resolver/index_specification.rb2
-rw-r--r--lib/rubygems/resolver/installer_set.rb4
-rw-r--r--lib/rubygems/security/policy.rb7
-rw-r--r--lib/rubygems/source/local.rb2
-rw-r--r--test/rubygems/helper.rb10
-rw-r--r--test/rubygems/package/tar_test_case.rb2
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb2
-rw-r--r--test/rubygems/test_gem_installer.rb2
20 files changed, 27 insertions, 56 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index ecd29c91e2..de0c8b84c3 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -948,7 +948,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
elapsed = Time.now - now
- ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display
+ ui.say format("%2$*1$s: %3$3.3fs", -width, msg, elapsed) if display
value
end
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index e0192c41e6..043e7d3691 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -343,7 +343,7 @@ platform.
end
summary = wrap(summary, summary_width).split "\n"
- out << sprintf(format, cmd_name, summary.shift)
+ out << format(format, cmd_name, summary.shift)
until summary.empty? do
out << "#{wrap_indent}#{summary.shift}"
end
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index 248060765b..00eff2dfe7 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -74,11 +74,9 @@ class Gem::Dependency
def inspect # :nodoc:
if prerelease?
- "<%s type=%p name=%p requirements=%p prerelease=ok>" %
- [self.class, type, name, requirement.to_s]
+ format("<%s type=%p name=%p requirements=%p prerelease=ok>", self.class, type, name, requirement.to_s)
else
- "<%s type=%p name=%p requirements=%p>" %
- [self.class, type, name, requirement.to_s]
+ format("<%s type=%p name=%p requirements=%p>", self.class, type, name, requirement.to_s)
end
end
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index 95a58f803d..30098ff0b5 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -105,7 +105,7 @@ class Gem::DependencyList
end
def inspect # :nodoc:
- "%s %p>" % [super[0..-2], map(&:full_name)]
+ format("%s %p>", super[0..-2], map(&:full_name))
end
##
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index 43bb1ccc86..58a6c5b7dc 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -109,7 +109,7 @@ module Gem::Deprecate
msg = [
"NOTE: #{target}#{name} is deprecated",
repl == :none ? " with no replacement" : "; use #{repl} instead",
- ". It will be removed on or after %4d-%02d." % [year, month],
+ format(". It will be removed on or after %4d-%02d.", year, month),
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Gem::Deprecate.skip
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index 4c2f7b896e..be6c34dc85 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -134,11 +134,7 @@ module Gem
##
# A wordy description of the error.
def wordy
- "Found %s (%s), but was for platform%s %s" %
- [@name,
- @version,
- @platforms.size == 1 ? "" : "s",
- @platforms.join(" ,")]
+ format("Found %s (%s), but was for platform%s %s", @name, @version, @platforms.size == 1 ? "" : "s", @platforms.join(" ,"))
end
end
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index 3ac6d34d13..c39afc9c9d 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -30,13 +30,13 @@ class Gem::Ext::Builder
make_program = Shellwords.split(make_program_name)
# The installation of the bundled gems is failed when DESTDIR is empty in mswin platform.
- destdir = /\bnmake/i !~ make_program_name || ENV["DESTDIR"] && ENV["DESTDIR"] != "" ? "DESTDIR=%s" % ENV["DESTDIR"] : ""
+ destdir = /\bnmake/i !~ make_program_name || ENV["DESTDIR"] && ENV["DESTDIR"] != "" ? format("DESTDIR=%s", ENV["DESTDIR"]) : ""
env = [destdir]
if sitedir
- env << "sitearchdir=%s" % sitedir
- env << "sitelibdir=%s" % sitedir
+ env << format("sitearchdir=%s", sitedir)
+ env << format("sitelibdir=%s", sitedir)
end
targets.each do |target|
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 7cea01610f..c3f91ebc34 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -70,15 +70,13 @@ class Gem::Package
class PathError < Error
def initialize(destination, destination_dir)
- super "installing into parent path %s of %s is not allowed" %
- [destination, destination_dir]
+ super format("installing into parent path %s of %s is not allowed", destination, destination_dir)
end
end
class SymlinkError < Error
def initialize(name, destination, destination_dir)
- super "installing symlink '%s' pointing to parent path %s of %s is not allowed" %
- [name, destination, destination_dir]
+ super format("installing symlink '%s' pointing to parent path %s of %s is not allowed", name, destination, destination_dir)
end
end
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index 11d66210a4..062a943942 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -241,6 +241,6 @@ class Gem::Package::TarHeader
end
def oct(num, len)
- "%0#{len}o" % num
+ format("%0#{len}o", num)
end
end
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index e8b1d68ed4..fc9ff58f57 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -92,9 +92,7 @@ class Gem::Resolver::ActivationRequest
end
def inspect # :nodoc:
- "#<%s for %p from %s>" % [
- self.class, @spec, @request
- ]
+ format("#<%s for %p from %s>", self.class, @spec, @request)
end
##
diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb
index 53a0afcc45..367a36b43d 100644
--- a/lib/rubygems/resolver/conflict.rb
+++ b/lib/rubygems/resolver/conflict.rb
@@ -64,10 +64,7 @@ class Gem::Resolver::Conflict
%s
MATCHING
- matching = matching % [
- dependency,
- alternates.join(", "),
- ]
+ matching = format(matching, dependency, alternates.join(", "))
end
explanation = <<-EXPLANATION
@@ -82,12 +79,7 @@ class Gem::Resolver::Conflict
%s
EXPLANATION
- explanation % [
- activated, requirement,
- request_path(@activated).reverse.join(", depends on\n "),
- request_path(@failed_dep).reverse.join(", depends on\n "),
- matching
- ]
+ format(explanation, activated, requirement, request_path(@activated).reverse.join(", depends on\n "), request_path(@failed_dep).reverse.join(", depends on\n "), matching)
end
##
diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb
index 6fac8c1487..b23807682b 100644
--- a/lib/rubygems/resolver/index_specification.rb
+++ b/lib/rubygems/resolver/index_specification.rb
@@ -68,7 +68,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
end
def inspect # :nodoc:
- "#<%s %s source %s>" % [self.class, full_name, @source]
+ format("#<%s %s source %s>", self.class, full_name, @source)
end
def pretty_print(q) # :nodoc:
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index 8b852fab11..b0e3241a1a 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -187,9 +187,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
def inspect # :nodoc:
always_install = @always_install.map(&:full_name)
- "#<%s domain: %s specs: %p always install: %p>" % [
- self.class, @domain, @specs.keys, always_install
- ]
+ format("#<%s domain: %s specs: %p always install: %p>", self.class, @domain, @specs.keys, always_install)
end
##
diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb
index 473262b761..7b86ac5763 100644
--- a/lib/rubygems/security/policy.rb
+++ b/lib/rubygems/security/policy.rb
@@ -192,11 +192,8 @@ class Gem::Security::Policy
end
def inspect # :nodoc:
- "[Policy: %s - data: %p signer: %p chain: %p root: %p " \
- "signed-only: %p trusted-only: %p]" % [
- @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
- @only_signed, @only_trusted
- ]
+ format("[Policy: %s - data: %p signer: %p chain: %p root: %p " \
+ "signed-only: %p trusted-only: %p]", @name, @verify_chain, @verify_data, @verify_root, @verify_signer, @only_signed, @only_trusted)
end
##
diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb
index 2018c24c8c..533b0a4d06 100644
--- a/lib/rubygems/source/local.rb
+++ b/lib/rubygems/source/local.rb
@@ -29,7 +29,7 @@ class Gem::Source::Local < Gem::Source
def inspect # :nodoc:
keys = @specs ? @specs.keys.sort : "NOT LOADED"
- "#<%s specs: %p>" % [self.class, keys]
+ format("#<%s specs: %p>", self.class, keys)
end
def load_specs(type) # :nodoc:
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index 4b9fc258dc..be43e2a26c 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -252,16 +252,10 @@ class Gem::TestCase < Test::Unit::TestCase
def assert_contains_make_command(target, output, msg = nil)
if output.include?("\n")
msg = build_message(msg,
- "Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT" % [
- ("%s %s" % [make_command, target]).rstrip,
- output,
- ])
+ format("Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT", format("%s %s", make_command, target).rstrip, output))
else
msg = build_message(msg,
- 'Expected make command "%s", but was "%s"' % [
- ("%s %s" % [make_command, target]).rstrip,
- output,
- ])
+ format('Expected make command "%s", but was "%s"', format("%s %s", make_command, target).rstrip, output))
end
assert scan_make_command_lines(output).any? {|line|
diff --git a/test/rubygems/package/tar_test_case.rb b/test/rubygems/package/tar_test_case.rb
index 710f589169..6033c87415 100644
--- a/test/rubygems/package/tar_test_case.rb
+++ b/test/rubygems/package/tar_test_case.rb
@@ -124,7 +124,7 @@ class Gem::Package::TarTestCase < Gem::TestCase
end
def to_oct(n, pad_size)
- "%0#{pad_size}o" % n
+ format("%0#{pad_size}o", n)
end
def util_entry(tar)
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index 2fb2b1ef9a..e5c3be1c7a 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -158,7 +158,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_path_exist gem_exec
- ruby_exec = sprintf Gem.default_exec_format, "ruby"
+ ruby_exec = format Gem.default_exec_format, "ruby"
bin_env = Gem.win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " "
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index a0e4a3803a..41fe4e0045 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -138,7 +138,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.options[:env_shebang] = true
@cmd.execute
- ruby_exec = sprintf Gem.default_exec_format, "ruby"
+ ruby_exec = format Gem.default_exec_format, "ruby"
bin_env = Gem.win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " "
assert_match(/\A#!\s*#{bin_env}#{ruby_exec}/, File.read(default_gem_bin_path))
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index b01a6039ff..965f05616b 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -987,7 +987,7 @@ gem 'other', version
assert_path_exist exe
exe_mode = File.stat(exe).mode & 0111
- assert_equal 0111, exe_mode, "0%o" % exe_mode unless Gem.win_platform?
+ assert_equal 0111, exe_mode, format("0%o", exe_mode) unless Gem.win_platform?
assert_path_exist File.join gemdir, "lib", "code.rb"