зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] util/rubocop -A --only Style/FormatString
https://github.com/rubygems/rubygems/commit/132a56569d
This commit is contained in:
Родитель
84ce6fc873
Коммит
250e97c0fb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -241,6 +241,6 @@ class Gem::Package::TarHeader
|
|||
end
|
||||
|
||||
def oct(num, len)
|
||||
"%0#{len}o" % num
|
||||
format("%0#{len}o", num)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) } + " "
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче