Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Layout/LeadingEmptyLines:
Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceBeforeBlockBraces:
Enabled: true

Layout/SpaceInsideBlockBraces:
Enabled: true
SpaceBeforeBlockParameters: false
Expand Down
3 changes: 3 additions & 0 deletions .rubocop_bundler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ Layout/SpaceInsideArrayLiteralBrackets:
Layout/SpaceInsideArrayPercentLiteral:
Enabled: true

Layout/SpaceBeforeBlockBraces:
Enabled: true

Layout/SpaceInsideBlockBraces:
Enabled: true
SpaceBeforeBlockParameters: false
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.without_groups_message(command)
end

def self.verbalize_groups(groups)
groups.map!{|g| "'#{g}'" }
groups.map! {|g| "'#{g}'" }
group_list = [groups[0...-1].join(", "), groups[-1..-1]].
reject {|s| s.to_s.empty? }.join(" and ")
group_str = groups.size == 1 ? "group" : "groups"
Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def resolve
@locked_specs
elsif !unlocking? && nothing_changed?
Bundler.ui.debug("Found no changes, using resolution from the lockfile")
SpecSet.new(filter_specs(@locked_specs, @dependencies.select{|dep| @locked_specs[dep].any? }))
SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
else
last_resolve = converge_locked_specs
# Run a resolve against the locally available gems
Expand Down Expand Up @@ -731,7 +731,7 @@ def converge_specs(specs)
end
end

SpecSet.new(filter_specs(converged, deps).reject{|s| @unlock[:gems].include?(s.name) })
SpecSet.new(filter_specs(converged, deps).reject {|s| @unlock[:gems].include?(s.name) })
end

def metadata_dependencies
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def eval_gemfile(gemfile, contents = nil)
@gemfile = expanded_gemfile_path
@gemfiles << expanded_gemfile_path
contents ||= Bundler.read_file(@gemfile.to_s)
instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
rescue Exception => e # rubocop:disable Lint/RescueException
message = "There was an error " \
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/gem_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def select_best_platform_match(specs, platform)
sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
exemplary_spec = sorted_matching.first

sorted_matching.take_while{|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
end
module_function :select_best_platform_match

Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.resolve(requirements, source_requirements = {}, base = [], gem_version_
base = SpecSet.new(base) unless base.is_a?(SpecSet)
resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
result = resolver.start(requirements)
SpecSet.new(SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") }))
SpecSet.new(SpecSet.new(result).for(requirements.reject {|dep| dep.name.end_with?("\0") }))
end

def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def source

def full_gem_path
if source.respond_to?(:root)
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
else
rg_full_gem_path
end
Expand Down
10 changes: 5 additions & 5 deletions bundler/lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ module SharedHelpers
def root
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
end

def default_gemfile
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
end

def default_lockfile
Expand All @@ -28,7 +28,7 @@ def default_lockfile
case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock")
end.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
end

def default_bundle_dir
Expand Down Expand Up @@ -100,7 +100,7 @@ def set_bundle_environment
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block)
yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" })
yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
rescue Errno::EACCES
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
Expand Down Expand Up @@ -236,7 +236,7 @@ def find_directory(*names)

def search_up(*names)
previous = nil
current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }

until !File.directory?(current) || current == previous
if ENV["BUNDLER_SPEC_RUN"]
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def validate_spec(_spec); end

def load_gemspec(file)
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
StubSpecification.from_stub(stub)
end

Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/spec_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def for(dependencies, check = false, match_current_platform = false)

loop do
break unless dep = deps.shift
next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"

handled << dep

Expand Down Expand Up @@ -172,7 +172,7 @@ def tsort_each_node
def spec_for_dependency(dep, match_current_platform)
specs_for_platforms = lookup[dep.name]
if match_current_platform
GemHelpers.select_best_platform_match(specs_for_platforms.select{|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
else
GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
end
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/runtime/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def script(code, options = {})

expect(out).to include("Installing activesupport")
err_lines = err.split("\n")
err_lines.reject!{|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7"
err_lines.reject! {|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7"
expect(err_lines).to be_empty
end

Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/support/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def gem_activate_and_possibly_install(gem_name)

def gem_activate(gem_name)
require "bundler"
gem_requirement = Bundler::LockfileParser.new(File.read(dev_lockfile)).specs.find{|spec| spec.name == gem_name }.version
gem_requirement = Bundler::LockfileParser.new(File.read(dev_lockfile)).specs.find {|spec| spec.name == gem_name }.version
gem gem_name, gem_requirement
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module Gem
# Taint support is deprecated in Ruby 2.7.
# This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
# to avoid deprecation warnings in Ruby 2.7.
UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc{}
UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc {}

# When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn
KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" ||
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/pristine_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def execute
end.flatten
end

specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
specs = specs.select {|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }

if specs.to_a.empty?
raise Gem::Exception,
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def generate_default_dirs
def files_in(dir)
Dir.chdir dir do
Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
select{|f| !File.directory?(f) }
select {|f| !File.directory?(f) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/specification_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def execute
platform = get_platform_from_requirements(options)

if platform
specs = specs.select{|s| s.platform.to_s == platform }
specs = specs.select {|s| s.platform.to_s == platform }
end

unless options[:all]
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,11 @@ def verify_spec
raise Gem::InstallError, "#{spec} has an invalid name"
end

if spec.raw_require_paths.any?{|path| path =~ /\R/ }
if spec.raw_require_paths.any? {|path| path =~ /\R/ }
raise Gem::InstallError, "#{spec} has an invalid require_paths"
end

if spec.extensions.any?{|ext| ext =~ /\R/ }
if spec.extensions.any? {|ext| ext =~ /\R/ }
raise Gem::InstallError, "#{spec} has an invalid extensions"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/local_remote_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def accept_uri_http

valid_uri_schemes = ["http", "https", "file", "s3"]
unless valid_uri_schemes.include?(uri.scheme)
msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map{|s| "#{s}://" }}"
msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map {|s| "#{s}://" }}"
raise ArgumentError, msg
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/query_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def execute
gem_names = if args.empty?
[options[:name]]
else
options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
options[:exact] ? args.map {|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map {|arg| /#{arg}/i }
end

terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems?
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/spec_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def search_for_dependency(dependency, matching_platform=true)

list.each do |source, specs|
if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
start_index = (0 ... specs.length).bsearch{|i| specs[i].name >= dependency.name }
end_index = (0 ... specs.length).bsearch{|i| specs[i].name > dependency.name }
start_index = (0 ... specs.length).bsearch {|i| specs[i].name >= dependency.name }
end_index = (0 ... specs.length).bsearch {|i| specs[i].name > dependency.name }
specs = specs[start_index ... end_index] if start_index && end_index
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ def self._latest_specs(specs, prerelease = false) # :nodoc:
result[spec.name] = spec
end

result.map(&:last).flatten.sort_by{|tup| tup.name }
result.map(&:last).flatten.sort_by {|tup| tup.name }
end

##
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ def ruby_with_rubygems_in_load_path
end

def rubygems_path
$LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) }
$LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }
end

def with_clean_path_to_ruby
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/package/tar_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def assert_headers_equal(expected, actual)
end

def calc_checksum(header)
sum = header.unpack("C*").inject{|s,a| s + a }
sum = header.unpack("C*").inject {|s,a| s + a }
SP(Z(to_oct(sum, 6)))
end

Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def test_self_refresh_keeps_loaded_specs_activated

Gem.refresh

Gem::Specification.each{|spec| assert spec.activated? if spec == s }
Gem::Specification.each {|spec| assert spec.activated? if spec == s }

Gem.loaded_specs.delete(s)
Gem.refresh
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_commands_contents_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_execute_default_gem
[RbConfig::CONFIG['bindir'], 'default_command'],
[RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'],
[RbConfig::CONFIG['archdir'], 'default_gem.so'],
].sort.map{|a|File.join a }.join "\n"
].sort.map {|a|File.join a }.join "\n"

assert_equal expected, @ui.output.chomp
assert_equal "", @ui.error
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_gem_commands_install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def test_execute_prerelease_skipped_when_non_pre_available
end

def test_execute_required_ruby_version
next_ruby = Gem.ruby_version.segments.map.with_index{|n, i| i == 1 ? n + 1 : n }.join(".")
next_ruby = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".")

local = Gem::Platform.local
spec_fetcher do |fetcher|
Expand Down Expand Up @@ -610,7 +610,7 @@ def test_execute_required_ruby_version_specific_prerelease_met
end

def test_execute_required_ruby_version_specific_prerelease_not_met
next_ruby_pre = Gem.ruby_version.segments.map.with_index{|n, i| i == 1 ? n + 1 : n }.join(".") + ".a"
next_ruby_pre = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".") + ".a"

spec_fetcher do |fetcher|
fetcher.gem 'a', '1.0' do |s|
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_request_set_lockfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_parse_GEM_remote_multiple
assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name }

assert_equal %w[https://gems.example/ https://other.example/],
lockfile_set.specs.flat_map {|s| s.sources.map{|src| src.uri.to_s } }
lockfile_set.specs.flat_map {|s| s.sources.map {|src| src.uri.to_s } }
end

def test_parse_GIT
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_resolver_installer_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_prefetch
def (set.remote_set).prefetch(_)
raise "called"
end
assert_raise(RuntimeError){ set.prefetch(nil) }
assert_raise(RuntimeError) { set.prefetch(nil) }

set = Gem::Resolver::InstallerSet.new :local
def (set.remote_set).prefetch(_)
Expand Down
12 changes: 6 additions & 6 deletions test/rubygems/test_gem_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,8 @@ def test_self_stubs_for_lazy_loading

dir_standard_specs = File.join Gem.dir, 'specifications'

save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' }
save_gemspec('b-1', '1', dir_standard_specs){|s| s.name = 'b' }
save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' }
save_gemspec('b-1', '1', dir_standard_specs) {|s| s.name = 'b' }

assert_equal ['a-1'], Gem::Specification.stubs_for('a').map {|s| s.full_name }
assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length
Expand All @@ -1013,7 +1013,7 @@ def test_self_stubs_for_lazy_loading
def test_self_stubs_for_no_lazy_loading_after_all_specs_setup
Gem::Specification.all = [util_spec('a', '1')]

save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')){|s| s.name = 'b' }
save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')) {|s| s.name = 'b' }

assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name }
end
Expand Down Expand Up @@ -1060,9 +1060,9 @@ def test_self_stubs_for_mult_platforms
def test_self_stubs_returns_only_specified_named_specs
dir_standard_specs = File.join Gem.dir, 'specifications'

save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' }
save_gemspec('a-2', '2', dir_standard_specs){|s| s.name = 'a' }
save_gemspec('a-a', '3', dir_standard_specs){|s| s.name = 'a-a' }
save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' }
save_gemspec('a-2', '2', dir_standard_specs) {|s| s.name = 'a' }
save_gemspec('a-a', '3', dir_standard_specs) {|s| s.name = 'a-a' }

assert_equal ['a-1', 'a-2'], Gem::Specification.stubs_for('a').map(&:full_name).sort
end
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def test_concurrent_require

install_specs a1, b1

t1 = create_sync_thread{ assert_require "a#{$$}" }
t2 = create_sync_thread{ assert_require "b#{$$}" }
t1 = create_sync_thread { assert_require "a#{$$}" }
t2 = create_sync_thread { assert_require "b#{$$}" }

# wait until both files are waiting on the exit latch
FILE_ENTERED_LATCH.await
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ def util_install_operating_system_rb(content)
end

def ruby_with_rubygems_and_fake_operating_system_in_load_path(operating_system_path)
[Gem.ruby, "-I", operating_system_path, "-I" , $LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) }]
[Gem.ruby, "-I", operating_system_path, "-I" , $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }]
end
end