summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2024-11-18 20:53:48 +0100
committerHiroshi SHIBATA <[email protected]>2024-11-26 15:11:05 +0900
commit963f98a94f978552c9ceb413dab085d2cdfc1236 (patch)
tree19043e52ff1637468418faef6aaa81eba3ddf017 /lib/rubygems
parent4addaaf4df9a7b48c3490b806c195fcb7be999b5 (diff)
[rubygems/rubygems] Enable `Performance/MapCompact` cop
https://github.com/rubygems/rubygems/commit/0c3a65871a
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/commands/contents_command.rb4
-rw-r--r--lib/rubygems/ext/cargo_builder.rb3
-rw-r--r--lib/rubygems/resolver.rb2
-rw-r--r--lib/rubygems/source/git.rb4
4 files changed, 6 insertions, 7 deletions
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 390ae2a923..d4f9871868 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -102,7 +102,7 @@ prefix or only the files that are requireable.
end
def files_in_default_gem(spec)
- spec.files.map do |file|
+ spec.files.filter_map do |file|
if file.start_with?("#{spec.bindir}/")
[RbConfig::CONFIG["bindir"], file.delete_prefix("#{spec.bindir}/")]
else
@@ -119,7 +119,7 @@ prefix or only the files that are requireable.
[resolve.delete_suffix(requirable_part), requirable_part]
end
- end.compact
+ end
end
def gem_contents(name)
diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb
index 81b28c3c77..453f8d5bcb 100644
--- a/lib/rubygems/ext/cargo_builder.rb
+++ b/lib/rubygems/ext/cargo_builder.rb
@@ -252,8 +252,7 @@ EOF
def rustc_dynamic_linker_flags(dest_dir, crate_name)
split_flags("DLDFLAGS").
- map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir, crate_name) }.
- compact.
+ filter_map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir, crate_name) }.
flat_map {|arg| ldflag_to_link_modifier(arg) }
end
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index 6b74c2527a..35d83abd2d 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -183,7 +183,7 @@ class Gem::Resolver
# Proceed with resolution! Returns an array of ActivationRequest objects.
def resolve
- Gem::Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }).tsort.map(&:payload).compact
+ Gem::Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }).tsort.filter_map(&:payload)
rescue Gem::Molinillo::VersionConflict => e
conflict = e.conflicts.values.first
raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
index 34f6851bc4..f229e1a7be 100644
--- a/lib/rubygems/source/git.rb
+++ b/lib/rubygems/source/git.rb
@@ -201,7 +201,7 @@ class Gem::Source::Git < Gem::Source
return [] unless install_dir
Dir.chdir install_dir do
- Dir["{,*,*/*}.gemspec"].map do |spec_file|
+ Dir["{,*,*/*}.gemspec"].filter_map do |spec_file|
directory = File.dirname spec_file
file = File.basename spec_file
@@ -218,7 +218,7 @@ class Gem::Source::Git < Gem::Source
end
spec
end
- end.compact
+ end
end
end