[rubygems/rubygems] util/rubocop -A --only Style/FormatString
https://github.com/rubygems/rubygems/commit/132a56569d
This commit is contained in:
parent
84ce6fc873
commit
250e97c0fb
@ -948,7 +948,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||||||
|
|
||||||
elapsed = Time.now - now
|
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
|
value
|
||||||
end
|
end
|
||||||
|
@ -343,7 +343,7 @@ platform.
|
|||||||
end
|
end
|
||||||
|
|
||||||
summary = wrap(summary, summary_width).split "\n"
|
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
|
until summary.empty? do
|
||||||
out << "#{wrap_indent}#{summary.shift}"
|
out << "#{wrap_indent}#{summary.shift}"
|
||||||
end
|
end
|
||||||
|
@ -74,11 +74,9 @@ class Gem::Dependency
|
|||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
if prerelease?
|
if prerelease?
|
||||||
"<%s type=%p name=%p requirements=%p prerelease=ok>" %
|
format("<%s type=%p name=%p requirements=%p prerelease=ok>", self.class, type, name, requirement.to_s)
|
||||||
[self.class, type, name, requirement.to_s]
|
|
||||||
else
|
else
|
||||||
"<%s type=%p name=%p requirements=%p>" %
|
format("<%s type=%p name=%p requirements=%p>", self.class, type, name, requirement.to_s)
|
||||||
[self.class, type, name, requirement.to_s]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class Gem::DependencyList
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
"%s %p>" % [super[0..-2], map(&:full_name)]
|
format("%s %p>", super[0..-2], map(&:full_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -109,7 +109,7 @@ module Gem::Deprecate
|
|||||||
msg = [
|
msg = [
|
||||||
"NOTE: #{target}#{name} is deprecated",
|
"NOTE: #{target}#{name} is deprecated",
|
||||||
repl == :none ? " with no replacement" : "; use #{repl} instead",
|
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(":")}",
|
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
|
||||||
]
|
]
|
||||||
warn "#{msg.join}." unless Gem::Deprecate.skip
|
warn "#{msg.join}." unless Gem::Deprecate.skip
|
||||||
|
@ -134,11 +134,7 @@ module Gem
|
|||||||
##
|
##
|
||||||
# A wordy description of the error.
|
# A wordy description of the error.
|
||||||
def wordy
|
def wordy
|
||||||
"Found %s (%s), but was for platform%s %s" %
|
format("Found %s (%s), but was for platform%s %s", @name, @version, @platforms.size == 1 ? "" : "s", @platforms.join(" ,"))
|
||||||
[@name,
|
|
||||||
@version,
|
|
||||||
@platforms.size == 1 ? "" : "s",
|
|
||||||
@platforms.join(" ,")]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ class Gem::Ext::Builder
|
|||||||
make_program = Shellwords.split(make_program_name)
|
make_program = Shellwords.split(make_program_name)
|
||||||
|
|
||||||
# The installation of the bundled gems is failed when DESTDIR is empty in mswin platform.
|
# 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]
|
env = [destdir]
|
||||||
|
|
||||||
if sitedir
|
if sitedir
|
||||||
env << "sitearchdir=%s" % sitedir
|
env << format("sitearchdir=%s", sitedir)
|
||||||
env << "sitelibdir=%s" % sitedir
|
env << format("sitelibdir=%s", sitedir)
|
||||||
end
|
end
|
||||||
|
|
||||||
targets.each do |target|
|
targets.each do |target|
|
||||||
|
@ -70,15 +70,13 @@ class Gem::Package
|
|||||||
|
|
||||||
class PathError < Error
|
class PathError < Error
|
||||||
def initialize(destination, destination_dir)
|
def initialize(destination, destination_dir)
|
||||||
super "installing into parent path %s of %s is not allowed" %
|
super format("installing into parent path %s of %s is not allowed", destination, destination_dir)
|
||||||
[destination, destination_dir]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class SymlinkError < Error
|
class SymlinkError < Error
|
||||||
def initialize(name, destination, destination_dir)
|
def initialize(name, destination, destination_dir)
|
||||||
super "installing symlink '%s' pointing to parent path %s of %s is not allowed" %
|
super format("installing symlink '%s' pointing to parent path %s of %s is not allowed", name, destination, destination_dir)
|
||||||
[name, destination, destination_dir]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -241,6 +241,6 @@ class Gem::Package::TarHeader
|
|||||||
end
|
end
|
||||||
|
|
||||||
def oct(num, len)
|
def oct(num, len)
|
||||||
"%0#{len}o" % num
|
format("%0#{len}o", num)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,9 +92,7 @@ class Gem::Resolver::ActivationRequest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
"#<%s for %p from %s>" % [
|
format("#<%s for %p from %s>", self.class, @spec, @request)
|
||||||
self.class, @spec, @request
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -64,10 +64,7 @@ class Gem::Resolver::Conflict
|
|||||||
%s
|
%s
|
||||||
MATCHING
|
MATCHING
|
||||||
|
|
||||||
matching = matching % [
|
matching = format(matching, dependency, alternates.join(", "))
|
||||||
dependency,
|
|
||||||
alternates.join(", "),
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
explanation = <<-EXPLANATION
|
explanation = <<-EXPLANATION
|
||||||
@ -82,12 +79,7 @@ class Gem::Resolver::Conflict
|
|||||||
%s
|
%s
|
||||||
EXPLANATION
|
EXPLANATION
|
||||||
|
|
||||||
explanation % [
|
format(explanation, activated, requirement, request_path(@activated).reverse.join(", depends on\n "), request_path(@failed_dep).reverse.join(", depends on\n "), matching)
|
||||||
activated, requirement,
|
|
||||||
request_path(@activated).reverse.join(", depends on\n "),
|
|
||||||
request_path(@failed_dep).reverse.join(", depends on\n "),
|
|
||||||
matching
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -68,7 +68,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
"#<%s %s source %s>" % [self.class, full_name, @source]
|
format("#<%s %s source %s>", self.class, full_name, @source)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pretty_print(q) # :nodoc:
|
def pretty_print(q) # :nodoc:
|
||||||
|
@ -187,9 +187,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
|
|||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
always_install = @always_install.map(&:full_name)
|
always_install = @always_install.map(&:full_name)
|
||||||
|
|
||||||
"#<%s domain: %s specs: %p always install: %p>" % [
|
format("#<%s domain: %s specs: %p always install: %p>", self.class, @domain, @specs.keys, always_install)
|
||||||
self.class, @domain, @specs.keys, always_install
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -192,11 +192,8 @@ class Gem::Security::Policy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
"[Policy: %s - data: %p signer: %p chain: %p root: %p " \
|
format("[Policy: %s - data: %p signer: %p chain: %p root: %p " \
|
||||||
"signed-only: %p trusted-only: %p]" % [
|
"signed-only: %p trusted-only: %p]", @name, @verify_chain, @verify_data, @verify_root, @verify_signer, @only_signed, @only_trusted)
|
||||||
@name, @verify_chain, @verify_data, @verify_root, @verify_signer,
|
|
||||||
@only_signed, @only_trusted
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -29,7 +29,7 @@ class Gem::Source::Local < Gem::Source
|
|||||||
|
|
||||||
def inspect # :nodoc:
|
def inspect # :nodoc:
|
||||||
keys = @specs ? @specs.keys.sort : "NOT LOADED"
|
keys = @specs ? @specs.keys.sort : "NOT LOADED"
|
||||||
"#<%s specs: %p>" % [self.class, keys]
|
format("#<%s specs: %p>", self.class, keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_specs(type) # :nodoc:
|
def load_specs(type) # :nodoc:
|
||||||
|
@ -252,16 +252,10 @@ class Gem::TestCase < Test::Unit::TestCase
|
|||||||
def assert_contains_make_command(target, output, msg = nil)
|
def assert_contains_make_command(target, output, msg = nil)
|
||||||
if output.include?("\n")
|
if output.include?("\n")
|
||||||
msg = build_message(msg,
|
msg = build_message(msg,
|
||||||
"Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_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))
|
||||||
("%s %s" % [make_command, target]).rstrip,
|
|
||||||
output,
|
|
||||||
])
|
|
||||||
else
|
else
|
||||||
msg = build_message(msg,
|
msg = build_message(msg,
|
||||||
'Expected make command "%s", but was "%s"' % [
|
format('Expected make command "%s", but was "%s"', format("%s %s", make_command, target).rstrip, output))
|
||||||
("%s %s" % [make_command, target]).rstrip,
|
|
||||||
output,
|
|
||||||
])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
assert scan_make_command_lines(output).any? {|line|
|
assert scan_make_command_lines(output).any? {|line|
|
||||||
|
@ -124,7 +124,7 @@ class Gem::Package::TarTestCase < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_oct(n, pad_size)
|
def to_oct(n, pad_size)
|
||||||
"%0#{pad_size}o" % n
|
format("%0#{pad_size}o", n)
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_entry(tar)
|
def util_entry(tar)
|
||||||
|
@ -158,7 +158,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|||||||
|
|
||||||
assert_path_exist gem_exec
|
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) } + " "
|
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.options[:env_shebang] = true
|
||||||
@cmd.execute
|
@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) } + " "
|
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))
|
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
|
assert_path_exist exe
|
||||||
|
|
||||||
exe_mode = File.stat(exe).mode & 0111
|
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"
|
assert_path_exist File.join gemdir, "lib", "code.rb"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user