diff --git a/lib/bundle/brew_dumper.rb b/lib/bundle/brew_dumper.rb index d49ad48f2..45b95c7f9 100644 --- a/lib/bundle/brew_dumper.rb +++ b/lib/bundle/brew_dumper.rb @@ -143,8 +143,8 @@ def formula_to_hash(formula) installed_as_dependency = tab.installed_as_dependency installed_on_request = tab.installed_on_request runtime_dependencies = if (runtime_deps = tab.runtime_dependencies) - runtime_deps.map { |d| d["full_name"] } - .compact + runtime_deps.filter_map { |d| d["full_name"] } + end poured_from_bottle = tab.poured_from_bottle end @@ -205,13 +205,13 @@ def sort!(formulae) # Step 2: Sort by formula dependency topology. topo = Topo.new formulae.each do |f| - topo[f[:name]] = topo[f[:full_name]] = f[:dependencies].map do |dep| + topo[f[:name]] = topo[f[:full_name]] = f[:dependencies].filter_map do |dep| ff = formulae_by_name(dep) next if ff.blank? next unless ff[:any_version_installed?] ff[:full_name] - end.compact + end end @formulae = topo.tsort .map { |name| @formulae_by_full_name[name] || @formulae_by_name[name] } diff --git a/lib/bundle/brew_installer.rb b/lib/bundle/brew_installer.rb index c7d2d4889..2b4d12d12 100644 --- a/lib/bundle/brew_installer.rb +++ b/lib/bundle/brew_installer.rb @@ -172,19 +172,19 @@ def self.upgradable_formulae end def self.outdated_formulae - @outdated_formulae ||= formulae.map { |f| f[:name] if f[:outdated?] }.compact + @outdated_formulae ||= formulae.filter_map { |f| f[:name] if f[:outdated?] } end def self.pinned_formulae - @pinned_formulae ||= formulae.map { |f| f[:name] if f[:pinned?] }.compact + @pinned_formulae ||= formulae.filter_map { |f| f[:name] if f[:pinned?] } end def self.linked_and_keg_only_formulae - @linked_and_keg_only_formulae ||= formulae.map { |f| f[:name] if f[:link?] == true }.compact + @linked_and_keg_only_formulae ||= formulae.filter_map { |f| f[:name] if f[:link?] == true } end def self.unlinked_and_not_keg_only_formulae - @unlinked_and_not_keg_only_formulae ||= formulae.map { |f| f[:name] if f[:link?] == false }.compact + @unlinked_and_not_keg_only_formulae ||= formulae.filter_map { |f| f[:name] if f[:link?] == false } end def self.formulae diff --git a/lib/bundle/brew_services.rb b/lib/bundle/brew_services.rb index 47cd14b00..c5fad2370 100644 --- a/lib/bundle/brew_services.rb +++ b/lib/bundle/brew_services.rb @@ -38,12 +38,12 @@ def started?(name) def started_services @started_services ||= if Bundle.services_installed? states_to_skip = %w[stopped none] - Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list").lines.map do |line| + Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list").lines.filter_map do |line| name, state, _plist = line.split(/\s+/) next if states_to_skip.include? state name - end.compact + end else [] end diff --git a/lib/bundle/cask_installer.rb b/lib/bundle/cask_installer.rb index 2e194a10d..345ea3ec1 100644 --- a/lib/bundle/cask_installer.rb +++ b/lib/bundle/cask_installer.rb @@ -37,7 +37,7 @@ def install(name, preinstall: true, no_upgrade: false, verbose: false, force: fa return Bundle.system HOMEBREW_BREW_FILE, "upgrade", "--cask", full_name, verbose: verbose end - args = options.fetch(:args, []).map do |k, v| + args = options.fetch(:args, []).filter_map do |k, v| case v when TrueClass "--#{k}" @@ -46,7 +46,7 @@ def install(name, preinstall: true, no_upgrade: false, verbose: false, force: fa else "--#{k}=#{v}" end - end.compact + end args << "--force" if force args.uniq! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bc6d8ed65..c7b6eaca2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,7 +51,7 @@ def linux? require "active_support/core_ext/enumerable" require "active_support/core_ext/hash/keys" -Dir.glob("#{PROJECT_ROOT}/lib/**/*.rb").sort.each do |file| +Dir.glob("#{PROJECT_ROOT}/lib/**/*.rb").each do |file| next if file.include?("/extend/os/") require file