[rubygems/rubygems] More aggressive Performance/FlatMap
cop configuration
https://github.com/rubygems/rubygems/commit/d8d68cc00e
This commit is contained in:
parent
11e522b913
commit
4addaaf4df
@ -581,12 +581,12 @@ module Bundler
|
|||||||
Bundler.rubygems.load_plugins
|
Bundler.rubygems.load_plugins
|
||||||
|
|
||||||
requested_path_gems = definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
|
requested_path_gems = definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
|
||||||
path_plugin_files = requested_path_gems.map do |spec|
|
path_plugin_files = requested_path_gems.flat_map do |spec|
|
||||||
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
|
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
|
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
|
||||||
raise Gem::InvalidSpecificationException, error_message
|
raise Gem::InvalidSpecificationException, error_message
|
||||||
end.flatten
|
end
|
||||||
Bundler.rubygems.load_plugin_files(path_plugin_files)
|
Bundler.rubygems.load_plugin_files(path_plugin_files)
|
||||||
Bundler.rubygems.load_env_plugins
|
Bundler.rubygems.load_env_plugins
|
||||||
@load_plugins_ran = true
|
@load_plugins_ran = true
|
||||||
|
@ -89,11 +89,11 @@ module Bundler
|
|||||||
|
|
||||||
if broken_links.any?
|
if broken_links.any?
|
||||||
message = "The following gems are missing OS dependencies:"
|
message = "The following gems are missing OS dependencies:"
|
||||||
broken_links.map do |spec, paths|
|
broken_links.flat_map do |spec, paths|
|
||||||
paths.uniq.map do |path|
|
paths.uniq.map do |path|
|
||||||
"\n * #{spec.name}: #{path}"
|
"\n * #{spec.name}: #{path}"
|
||||||
end
|
end
|
||||||
end.flatten.sort.each {|m| message += m }
|
end.sort.each {|m| message += m }
|
||||||
raise ProductionError, message
|
raise ProductionError, message
|
||||||
elsif !permissions_valid
|
elsif !permissions_valid
|
||||||
Bundler.ui.info "No issues found with the installed bundle"
|
Bundler.ui.info "No issues found with the installed bundle"
|
||||||
|
@ -345,7 +345,7 @@ module Bundler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def groups
|
def groups
|
||||||
dependencies.map(&:groups).flatten.uniq
|
dependencies.flat_map(&:groups).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
|
def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
|
||||||
|
@ -28,7 +28,7 @@ module Bundler
|
|||||||
private
|
private
|
||||||
|
|
||||||
def paths
|
def paths
|
||||||
@specs.map do |spec|
|
@specs.flat_map do |spec|
|
||||||
next if spec.name == "bundler"
|
next if spec.name == "bundler"
|
||||||
Array(spec.require_paths).map do |path|
|
Array(spec.require_paths).map do |path|
|
||||||
gem_path(path, spec).
|
gem_path(path, spec).
|
||||||
@ -36,7 +36,7 @@ module Bundler
|
|||||||
sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
|
sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
|
||||||
# This is a static string intentionally. It's interpolated at a later time.
|
# This is a static string intentionally. It's interpolated at a later time.
|
||||||
end
|
end
|
||||||
end.flatten.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def version_dir
|
def version_dir
|
||||||
|
@ -79,7 +79,7 @@ module Bundler
|
|||||||
def solve_versions(root:, logger:)
|
def solve_versions(root:, logger:)
|
||||||
solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
|
solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
|
||||||
result = solver.solve
|
result = solver.solve
|
||||||
resolved_specs = result.map {|package, version| version.to_specs(package) }.flatten
|
resolved_specs = result.flat_map {|package, version| version.to_specs(package) }
|
||||||
resolved_specs |= @base.specs_compatible_with(SpecSet.new(resolved_specs))
|
resolved_specs |= @base.specs_compatible_with(SpecSet.new(resolved_specs))
|
||||||
rescue PubGrub::SolveFailure => e
|
rescue PubGrub::SolveFailure => e
|
||||||
incompatibility = e.incompatibility
|
incompatibility = e.incompatibility
|
||||||
|
@ -38,9 +38,9 @@ module Bundler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dependencies
|
def dependencies
|
||||||
@dependencies ||= @specs.map do |spec|
|
@dependencies ||= @specs.flat_map do |spec|
|
||||||
__dependencies(spec) + metadata_dependencies(spec)
|
__dependencies(spec) + metadata_dependencies(spec)
|
||||||
end.flatten.uniq.sort
|
end.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
|
@ -91,7 +91,7 @@ module Bundler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rubygems_remotes
|
def rubygems_remotes
|
||||||
rubygems_sources.map(&:remotes).flatten.uniq
|
rubygems_sources.flat_map(&:remotes).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_sources
|
def all_sources
|
||||||
|
@ -496,9 +496,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||||||
|
|
||||||
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs
|
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs
|
||||||
|
|
||||||
files.concat gem_specifications.map {|spec|
|
files.concat gem_specifications.flat_map {|spec|
|
||||||
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
||||||
}.flatten
|
}
|
||||||
|
|
||||||
# $LOAD_PATH might contain duplicate entries or reference
|
# $LOAD_PATH might contain duplicate entries or reference
|
||||||
# the spec dirs directly, so we prune.
|
# the spec dirs directly, so we prune.
|
||||||
@ -509,9 +509,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||||||
|
|
||||||
def self.find_files_from_load_path(glob) # :nodoc:
|
def self.find_files_from_load_path(glob) # :nodoc:
|
||||||
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
|
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
|
||||||
$LOAD_PATH.map do |load_path|
|
$LOAD_PATH.flat_map do |load_path|
|
||||||
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
|
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
|
||||||
end.flatten.select {|file| File.file? file }
|
end.select {|file| File.file? file }
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -531,9 +531,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||||||
|
|
||||||
files = find_files_from_load_path glob if check_load_path
|
files = find_files_from_load_path glob if check_load_path
|
||||||
|
|
||||||
files.concat Gem::Specification.latest_specs(true).map {|spec|
|
files.concat Gem::Specification.latest_specs(true).flat_map {|spec|
|
||||||
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
||||||
}.flatten
|
}
|
||||||
|
|
||||||
# $LOAD_PATH might contain duplicate entries or reference
|
# $LOAD_PATH might contain duplicate entries or reference
|
||||||
# the spec dirs directly, so we prune.
|
# the spec dirs directly, so we prune.
|
||||||
|
@ -113,9 +113,9 @@ If no gems are named all gems in GEM_HOME are cleaned.
|
|||||||
@candidate_gems = if options[:args].empty?
|
@candidate_gems = if options[:args].empty?
|
||||||
Gem::Specification.to_a
|
Gem::Specification.to_a
|
||||||
else
|
else
|
||||||
options[:args].map do |gem_name|
|
options[:args].flat_map do |gem_name|
|
||||||
Gem::Specification.find_all_by_name gem_name
|
Gem::Specification.find_all_by_name gem_name
|
||||||
end.flatten
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,8 +189,8 @@ prefix or only the files that are requireable.
|
|||||||
end
|
end
|
||||||
|
|
||||||
def specification_directories # :nodoc:
|
def specification_directories # :nodoc:
|
||||||
options[:specdirs].map do |i|
|
options[:specdirs].flat_map do |i|
|
||||||
[i, File.join(i, "specifications")]
|
[i, File.join(i, "specifications")]
|
||||||
end.flatten
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -120,9 +120,9 @@ extensions will be restored.
|
|||||||
elsif options[:only_missing_extensions]
|
elsif options[:only_missing_extensions]
|
||||||
specification_record.select(&:missing_extensions?)
|
specification_record.select(&:missing_extensions?)
|
||||||
else
|
else
|
||||||
get_all_gem_names.sort.map do |gem_name|
|
get_all_gem_names.sort.flat_map do |gem_name|
|
||||||
specification_record.find_all_by_name(gem_name, options[:version]).reverse
|
specification_record.find_all_by_name(gem_name, options[:version]).reverse
|
||||||
end.flatten
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
|
specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
|
||||||
|
@ -64,9 +64,9 @@ Use --overwrite to force rebuilding of documentation.
|
|||||||
specs = if options[:all]
|
specs = if options[:all]
|
||||||
Gem::Specification.to_a
|
Gem::Specification.to_a
|
||||||
else
|
else
|
||||||
get_all_gem_names.map do |name|
|
get_all_gem_names.flat_map do |name|
|
||||||
Gem::Specification.find_by_name name, options[:version]
|
Gem::Specification.find_by_name name, options[:version]
|
||||||
end.flatten.uniq
|
end.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
if specs.empty?
|
if specs.empty?
|
||||||
|
@ -59,7 +59,7 @@ class Gem::Resolver
|
|||||||
def self.compose_sets(*sets)
|
def self.compose_sets(*sets)
|
||||||
sets.compact!
|
sets.compact!
|
||||||
|
|
||||||
sets = sets.map do |set|
|
sets = sets.flat_map do |set|
|
||||||
case set
|
case set
|
||||||
when Gem::Resolver::BestSet then
|
when Gem::Resolver::BestSet then
|
||||||
set
|
set
|
||||||
@ -68,7 +68,7 @@ class Gem::Resolver
|
|||||||
else
|
else
|
||||||
set
|
set
|
||||||
end
|
end
|
||||||
end.flatten
|
end
|
||||||
|
|
||||||
case sets.length
|
case sets.length
|
||||||
when 0 then
|
when 0 then
|
||||||
|
@ -44,16 +44,16 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
|
|||||||
end
|
end
|
||||||
|
|
||||||
def errors
|
def errors
|
||||||
@errors + @sets.map(&:errors).flatten
|
@errors + @sets.flat_map(&:errors)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Finds all specs matching +req+ in all sets.
|
# Finds all specs matching +req+ in all sets.
|
||||||
|
|
||||||
def find_all(req)
|
def find_all(req)
|
||||||
@sets.map do |s|
|
@sets.flat_map do |s|
|
||||||
s.find_all req
|
s.find_all req
|
||||||
end.flatten
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -65,11 +65,11 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
|||||||
|
|
||||||
q.breakable
|
q.breakable
|
||||||
|
|
||||||
names = @all.values.map do |tuples|
|
names = @all.values.flat_map do |tuples|
|
||||||
tuples.map do |_, tuple|
|
tuples.map do |_, tuple|
|
||||||
tuple.full_name
|
tuple.full_name
|
||||||
end
|
end
|
||||||
end.flatten
|
end
|
||||||
|
|
||||||
q.seplist names do |name|
|
q.seplist names do |name|
|
||||||
q.text name
|
q.text name
|
||||||
|
@ -1014,7 +1014,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.unresolved_specs
|
def self.unresolved_specs
|
||||||
unresolved_deps.values.map(&:to_specs).flatten
|
unresolved_deps.values.flat_map(&:to_specs)
|
||||||
end
|
end
|
||||||
private_class_method :unresolved_specs
|
private_class_method :unresolved_specs
|
||||||
|
|
||||||
@ -1073,7 +1073,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
result[spec.name] = spec
|
result[spec.name] = spec
|
||||||
end
|
end
|
||||||
|
|
||||||
result.map(&:last).flatten.sort_by(&:name)
|
result.flat_map(&:last).sort_by(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -1770,7 +1770,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
# Returns all specs that matches this spec's runtime dependencies.
|
# Returns all specs that matches this spec's runtime dependencies.
|
||||||
|
|
||||||
def dependent_specs
|
def dependent_specs
|
||||||
runtime_dependencies.map(&:to_specs).flatten
|
runtime_dependencies.flat_map(&:to_specs)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -67,14 +67,14 @@ class CompactIndexAPI < Endpoint
|
|||||||
@gems ||= {}
|
@gems ||= {}
|
||||||
@gems[gem_repo] ||= begin
|
@gems[gem_repo] ||= begin
|
||||||
specs = Bundler::Deprecate.skip_during do
|
specs = Bundler::Deprecate.skip_during do
|
||||||
%w[specs.4.8 prerelease_specs.4.8].map do |filename|
|
%w[specs.4.8 prerelease_specs.4.8].flat_map do |filename|
|
||||||
spec_index = gem_repo.join(filename)
|
spec_index = gem_repo.join(filename)
|
||||||
next [] unless File.exist?(spec_index)
|
next [] unless File.exist?(spec_index)
|
||||||
|
|
||||||
Marshal.load(File.binread(spec_index)).map do |name, version, platform|
|
Marshal.load(File.binread(spec_index)).map do |name, version, platform|
|
||||||
load_spec(name, version, platform, gem_repo)
|
load_spec(name, version, platform, gem_repo)
|
||||||
end
|
end
|
||||||
end.flatten
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specs.group_by(&:name).map do |name, versions|
|
specs.group_by(&:name).map do |name, versions|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user