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

https://github.com/rubygems/rubygems/commit/cb554f6eb7
This commit is contained in:
Hiroshi SHIBATA 2023-03-16 13:00:54 +09:00
Родитель 83f9aa8f02
Коммит 4bb5ce8188
36 изменённых файлов: 62 добавлений и 62 удалений

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

@ -903,7 +903,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Glob pattern for require-able path suffixes.
def self.suffix_pattern
@suffix_pattern ||= "{#{suffixes.join(',')}}"
@suffix_pattern ||= "{#{suffixes.join(",")}}"
end
##

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

@ -290,7 +290,7 @@ class Gem::BasicSpecification
def lib_dirs_glob
dirs = if self.raw_require_paths
if self.raw_require_paths.size > 1
"{#{self.raw_require_paths.join(',')}}"
"{#{self.raw_require_paths.join(",")}}"
else
self.raw_require_paths.first
end

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

@ -227,7 +227,7 @@ class Gem::Command
if args.size > 1
raise Gem::CommandLineError,
"Too many gem names (#{args.join(', ')}); please specify only one"
"Too many gem names (#{args.join(", ")}); please specify only one"
end
args.first

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

@ -200,7 +200,7 @@ class Gem::CommandManager
if possibilities.size > 1
raise Gem::CommandLineError,
"Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
"Ambiguous command #{cmd_name} matches [#{possibilities.join(", ")}]"
elsif possibilities.empty?
raise Gem::UnknownCommandError.new(cmd_name)
end

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

@ -89,7 +89,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
verbose do
skipped = @default_gems.map {|spec| spec.full_name }
"Skipped default gems: #{skipped.join ', '}"
"Skipped default gems: #{skipped.join ", "}"
end
end

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

@ -91,7 +91,7 @@ prefix or only the files that are requireable.
def files_in_gem(spec)
gem_path = spec.full_gem_path
extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
extra = "/{#{spec.require_paths.join ","}}" if options[:lib_only]
glob = "#{gem_path}#{extra}/**/*"
prefix_re = /#{Regexp.escape(gem_path)}\//

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

@ -327,7 +327,7 @@ platform.
summary_width = 80 - margin_width - desc_width
wrap_indent = " " * (margin_width + desc_width)
format = "#{' ' * margin_width}%-#{desc_width}s%s"
format = "#{" " * margin_width}%-#{desc_width}s%s"
@command_manager.command_names.each do |cmd_name|
command = @command_manager[cmd_name]
@ -366,7 +366,7 @@ platform.
command = @command_manager[possibilities.first]
command.invoke("--help")
elsif possibilities.size > 1
alert_warning "Ambiguous command #{command_name} (#{possibilities.join(', ')})"
alert_warning "Ambiguous command #{command_name} (#{possibilities.join(", ")})"
else
alert_warning "Unknown command #{command_name}. Try: gem help commands"
end

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

@ -78,7 +78,7 @@ permission to.
say "Owners for gem: #{name}"
owners.each do |owner|
say "- #{owner['email'] || owner['handle'] || owner['id']}"
say "- #{owner["email"] || owner["handle"] || owner["id"]}"
end
end
end

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

@ -133,7 +133,7 @@ prefix and suffix. If ruby was installed as `ruby18`, gem will be
installed as `gem18`.
By default, this RubyGems will install gem as:
#{Gem.default_exec_format % 'gem'}
#{Gem.default_exec_format % "gem"}
EOF
end

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

@ -33,7 +33,7 @@ longer using.
end
gem_to_atime.sort_by {|_, atime| atime }.each do |name, atime|
say "#{name} at #{atime.strftime '%c'}"
say "#{name} at #{atime.strftime "%c"}"
end
end
end

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

@ -127,10 +127,10 @@ command to remove old versions.
if updated.empty?
say "Nothing to update"
else
say "Gems updated: #{updated_names.join(' ')}"
say "Gems updated: #{updated_names.join(" ")}"
end
say "Gems already up-to-date: #{up_to_date_names.join(' ')}" unless up_to_date_names.empty?
say "Gems not currently installed: #{not_installed_names.join(' ')}" unless not_installed_names.empty?
say "Gems already up-to-date: #{up_to_date_names.join(" ")}" unless up_to_date_names.empty?
say "Gems not currently installed: #{not_installed_names.join(" ")}" unless not_installed_names.empty?
end
def fetch_remote_gems(spec) # :nodoc:

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

@ -38,7 +38,7 @@ module Kernel
if gem_name.kind_of? Gem::Dependency
unless Gem::Deprecate.skip
warn "#{Gem.location_of_caller.join ':'}:Warning: Kernel.gem no longer "\
warn "#{Gem.location_of_caller.join ":"}:Warning: Kernel.gem no longer "\
"accepts a Gem::Dependency object, please pass the name "\
"and requirements directly"
end

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

@ -126,7 +126,7 @@ module Kernel
if names.size > 1
RUBYGEMS_ACTIVATION_MONITOR.exit
raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ', '}"
raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ", "}"
end
# Ok, now find a gem that has no conflicts, starting

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

@ -32,7 +32,7 @@ class Gem::Doctor
Gem::REPOSITORY_SUBDIRECTORIES.sort -
REPOSITORY_EXTENSION_MAP.map {|(k,_)| k }.sort
raise "Update REPOSITORY_EXTENSION_MAP, missing: #{missing.join ', '}" unless
raise "Update REPOSITORY_EXTENSION_MAP, missing: #{missing.join ", "}" unless
missing.empty?
##

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

@ -60,7 +60,7 @@ module Gem
def build_message
names = specs.map(&:full_name)
"Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n"
"Could not find '#{name}' (#{requirement}) - did find: [#{names.join ","}]\n"
end
end

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

@ -255,7 +255,7 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
def initialize(dep, platform_mismatch=nil)
if platform_mismatch && !platform_mismatch.empty?
plats = platform_mismatch.map {|x| x.platform.to_s }.sort.uniq
super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(', ')}"
super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(", ")}"
else
if dep.explicit?
super "Unable to resolve dependency: user requested '#{dep}'"

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

@ -189,7 +189,7 @@ EOF
if @build_args.empty?
say "Building native extensions. This could take a while..."
else
say "Building native extensions with: '#{@build_args.join ' '}'"
say "Building native extensions with: '#{@build_args.join " "}'"
say "This could take a while..."
end

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

@ -211,7 +211,7 @@ module Gem::GemcutterUtilities
say clean_text(response.body)
end
when Net::HTTPPermanentRedirect, Net::HTTPRedirection then
message = "The request has redirected permanently to #{response['location']}. Please check your defined push host URL."
message = "The request has redirected permanently to #{response["location"]}. Please check your defined push host URL."
message = "#{error_prefix}: #{message}" if error_prefix
say clean_text(message)

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

@ -141,7 +141,7 @@ module Gem::InstallUpdateOptions
end unless v
unless v
message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ', '})"
message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ", "})"
raise Gem::OptionParser::InvalidArgument,
"cannot find gem dependencies file #{message}"

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

@ -807,7 +807,7 @@ TEXT
rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
# get ruby executable file name from RbConfig
ruby_exe = "#{rb_config['RUBY_INSTALL_NAME']}#{rb_config['EXEEXT']}"
ruby_exe = "#{rb_config["RUBY_INSTALL_NAME"]}#{rb_config["EXEEXT"]}"
ruby_exe = "ruby.exe" if ruby_exe.empty?
if File.exist?(File.join bindir, ruby_exe)

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

@ -692,7 +692,7 @@ EOM
end
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(', ')})"
raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(", ")})"
end
end

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

@ -263,7 +263,7 @@ module Gem::QueryUtils
end
end
entry << " (#{list.join ', '})"
entry << " (#{list.join ", "})"
end
def make_entry(entry_tuples, platforms)
@ -282,7 +282,7 @@ module Gem::QueryUtils
end
def spec_authors(entry, spec)
authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup
authors = "Author#{spec.authors.length > 1 ? "s" : ""}: ".dup
authors << spec.authors.join(", ")
entry << format_text(authors, 68, 4)
end
@ -296,7 +296,7 @@ module Gem::QueryUtils
def spec_license(entry, spec)
return if spec.license.nil? || spec.license.empty?
licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
licenses = "License#{spec.licenses.length > 1 ? "s" : ""}: ".dup
licenses << spec.licenses.join(", ")
entry << "\n" << format_text(licenses, 68, 4)
end
@ -327,7 +327,7 @@ module Gem::QueryUtils
if platforms.length == 1
title = platforms.values.length == 1 ? "Platform" : "Platforms"
entry << " #{title}: #{platforms.values.sort.join(', ')}\n"
entry << " #{title}: #{platforms.values.sort.join(", ")}\n"
else
entry << " Platforms:\n"

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

@ -163,7 +163,7 @@ class Gem::Requirement
"#{op} #{version}"
end.uniq
" (#{list.join ', '})"
" (#{list.join ", "})"
end
##

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

@ -28,7 +28,7 @@ module Gem::SecurityOption
policy = Gem::Security::Policies[value]
unless policy
valid = Gem::Security::Policies.keys.sort
raise Gem::OptionParser::InvalidArgument, "#{value} (#{valid.join ', '} are valid)"
raise Gem::OptionParser::InvalidArgument, "#{value} (#{valid.join ", "} are valid)"
end
policy
end

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

@ -2348,7 +2348,7 @@ class Gem::Specification < Gem::BasicSpecification
when Array then "[" + obj.map {|x| ruby_code x }.join(", ") + "]"
when Hash then
seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
"{ #{seg.join(', ')} }"
"{ #{seg.join(", ")} }"
when Gem::Version then obj.to_s.dump
when DateLike then obj.strftime("%Y-%m-%d").dump
when Time then obj.strftime("%Y-%m-%d").dump

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

@ -213,7 +213,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
end
" if #{dep.name} is semantically versioned, use:\n" \
" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join "."}'#{bugfix}"
end
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
@ -253,7 +253,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
@specification.instance_variable_get("@#{attrname}").nil?
end
return if nil_attributes.empty?
error "#{nil_attributes.join ', '} must not be nil"
error "#{nil_attributes.join ", "} must not be nil"
end
def validate_rubygems_version
@ -374,7 +374,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
license value '#{license}' is invalid. Use a license identifier from
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
WARNING
message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(', ')}?\n" unless suggestions.nil?
message += "Did you mean #{suggestions.map {|s| "'#{s}'" }.join(", ")}?\n" unless suggestions.nil?
warning(message)
end
end

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

@ -201,7 +201,7 @@ class Gem::Uninstaller
remove = if @force_executables.nil?
ask_yes_no("Remove executables:\n" +
"\t#{executables.join ', '}\n\n" +
"\t#{executables.join ", "}\n\n" +
"in addition to the gem?",
true)
else

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

@ -334,7 +334,7 @@ class Gem::TestCase < Test::Unit::TestCase
ruby
end
@git = ENV["GIT"] || "git#{RbConfig::CONFIG['EXEEXT']}"
@git = ENV["GIT"] || "git#{RbConfig::CONFIG["EXEEXT"]}"
Gem.ensure_gem_subdirectories @gemhome
Gem.ensure_default_gem_subdirectories @gemhome
@ -1256,7 +1256,7 @@ Also, a list:
ruby = ENV["RUBY"]
return ruby if ruby
ruby = "ruby"
rubyexe = "#{ruby}#{RbConfig::CONFIG['EXEEXT']}"
rubyexe = "#{ruby}#{RbConfig::CONFIG["EXEEXT"]}"
3.times do
if File.exist?(ruby) && File.executable?(ruby) && !File.directory?(ruby)
@ -1331,8 +1331,8 @@ Also, a list:
end
end
@@good_rake = "#{rubybin} #{escape_path(__dir__, 'good_rake.rb')}"
@@bad_rake = "#{rubybin} #{escape_path(__dir__, 'bad_rake.rb')}"
@@good_rake = "#{rubybin} #{escape_path(__dir__, "good_rake.rb")}"
@@bad_rake = "#{rubybin} #{escape_path(__dir__, "bad_rake.rb")}"
##
# Construct a new Gem::Dependency.

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

@ -664,7 +664,7 @@ class TestGem < Gem::TestCase
gemdir = File.join @tempdir, "a/b/c/gemdir"
FileUtils.rm_rf File.join(@tempdir, "a") rescue nil
refute File.exist?(File.join(@tempdir, "a")),
"manually remove #{File.join @tempdir, 'a'}, tests are broken"
"manually remove #{File.join @tempdir, "a"}, tests are broken"
Gem.use_paths gemdir
Gem.ensure_gem_subdirectories gemdir

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

@ -128,9 +128,9 @@ Added '/CN=alternate/DC=example'
output.shift
assert_equal "Please repeat the passphrase for your Private Key: ",
output.shift
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
output.shift
assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
assert_equal "Private Key: #{File.join @tempdir, "gem-private_key.pem"}",
output.shift
assert_equal "Don't forget to move the key file to somewhere private!",
@ -160,9 +160,9 @@ Added '/CN=alternate/DC=example'
output.shift
assert_equal "Please repeat the passphrase for your Private Key: ",
output.shift
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
output.shift
assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
assert_equal "Private Key: #{File.join @tempdir, "gem-private_key.pem"}",
output.shift
assert_equal "Don't forget to move the key file to somewhere private!",
@ -220,9 +220,9 @@ Added '/CN=alternate/DC=example'
output.shift
assert_equal "Please repeat the passphrase for your Private Key: ",
output.shift
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
output.shift
assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
assert_equal "Private Key: #{File.join @tempdir, "gem-private_key.pem"}",
output.shift
assert_equal "Don't forget to move the key file to somewhere private!",
@ -283,7 +283,7 @@ Added '/CN=alternate/DC=example'
output = @ui.output.split "\n"
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
output.shift
assert_empty output
@ -305,7 +305,7 @@ Added '/CN=alternate/DC=example'
output = @ui.output.split "\n"
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
output.shift
assert_empty output
@ -326,7 +326,7 @@ Added '/CN=alternate/DC=example'
output = @ui.output.split "\n"
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
assert_equal "Certificate: #{File.join @tempdir, "gem-public_cert.pem"}",
output.shift
assert_empty output

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

@ -105,7 +105,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
end
@response = "Successfully registered gem: freewill (1.0.0)"
@fetcher.data["#{@spec.metadata['allowed_push_host']}/api/v1/gems"] = HTTPResponseFactory.create(body: @response, code: 200, msg: "OK")
@fetcher.data["#{@spec.metadata["allowed_push_host"]}/api/v1/gems"] = HTTPResponseFactory.create(body: @response, code: 200, msg: "OK")
@fetcher.data["#{Gem.host}/api/v1/gems"] =
["fail", 500, "Internal Server Error"]

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

@ -210,7 +210,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase
# Set the expected response for the Web-API supplied
ENV["RUBYGEMS_HOST"] = host
data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key"
data_key = "#{ENV["RUBYGEMS_HOST"]}/api/v1/api_key"
fetcher.data[data_key] = HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
use_ui key_name_ui do
@ -241,9 +241,9 @@ class TestGemCommandsSigninCommand < Gem::TestCase
# Set the expected response for the Web-API supplied
ENV["RUBYGEMS_HOST"] = host || Gem::DEFAULT_HOST
data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key"
data_key = "#{ENV["RUBYGEMS_HOST"]}/api/v1/api_key"
fetcher.data[data_key] = response
profile = "#{ENV['RUBYGEMS_HOST']}/api/v1/profile/me.yaml"
profile = "#{ENV["RUBYGEMS_HOST"]}/api/v1/profile/me.yaml"
fetcher.data[profile] = profile_response
Gem::RemoteFetcher.fetcher = fetcher

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

@ -36,7 +36,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
end
output = output.join "\n"
bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG["DLEXT"]}")
assert_match(/Finished/, output)
assert_match(/release/, output)
@ -62,7 +62,7 @@ class TestGemExtCargoBuilder < Gem::TestCase
end
output = output.join "\n"
bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG["DLEXT"]}")
assert_ffi_handle bundle, "hello_from_rubygems"
assert_ffi_handle bundle, "hello_from_rubygems_version"

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

@ -1977,7 +1977,7 @@ gem 'other', version
bin_env = get_bin_env
assert_equal("#!#{bin_env} #{RbConfig::CONFIG['ruby_install_name']}",
assert_equal("#!#{bin_env} #{RbConfig::CONFIG["ruby_install_name"]}",
shebang)
end

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

@ -268,10 +268,10 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
def test_split_name
assert_equal ["b" * 100, "a" * 155],
@tar_writer.split_name("#{'a' * 155}/#{'b' * 100}")
@tar_writer.split_name("#{"a" * 155}/#{"b" * 100}")
assert_equal ["#{'qwer/' * 19}bla", "a" * 151],
@tar_writer.split_name("#{'a' * 151}/#{'qwer/' * 19}bla")
assert_equal ["#{"qwer/" * 19}bla", "a" * 151],
@tar_writer.split_name("#{"a" * 151}/#{"qwer/" * 19}bla")
names = [
([""] + ["123456789"] * 9 + ["1234567890"]).join("/"), # 101 bytes (several pieces)
(["123456789"] * 9 + ["1234567890"] + [""]).join("/"), # 101 bytes (several pieces)

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

@ -208,7 +208,7 @@ class TestGemRequest < Gem::TestCase
end
auth_header = conn.payload["Authorization"]
assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header
assert_equal "Basic #{Base64.encode64("user:pass")}".strip, auth_header
assert_includes @ui.output, "GET https://user:REDACTED@example.rubygems/specs.#{Gem.marshal_version}"
end
@ -225,7 +225,7 @@ class TestGemRequest < Gem::TestCase
end
auth_header = conn.payload["Authorization"]
assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header
assert_equal "Basic #{Base64.encode64("user:{DEScede}pass")}".strip, auth_header
assert_includes @ui.output, "GET https://user:REDACTED@example.rubygems/specs.#{Gem.marshal_version}"
end
@ -242,7 +242,7 @@ class TestGemRequest < Gem::TestCase
end
auth_header = conn.payload["Authorization"]
assert_equal "Basic #{Base64.encode64('{DEScede}pass:x-oauth-basic')}".strip, auth_header
assert_equal "Basic #{Base64.encode64("{DEScede}pass:x-oauth-basic")}".strip, auth_header
assert_includes @ui.output, "GET https://REDACTED:x-oauth-basic@example.rubygems/specs.#{Gem.marshal_version}"
end