Skip to content
Snippets Groups Projects
Commit ae0e2707 authored by Xu Cheng's avatar Xu Cheng
Browse files

favor flat_map over map...flatten

parent 4e5227fd
No related branches found
No related tags found
No related merge requests found
......@@ -242,7 +242,7 @@ class FormulaAuditor
if @online
same_name_tap_formulae += @@remote_official_taps.map do |tap|
Thread.new { Homebrew.search_tap "homebrew", tap, name }
end.map(&:value).flatten
end.flat_map(&:value)
end
same_name_tap_formulae.delete(full_name)
......
......@@ -26,7 +26,7 @@ module Homebrew
end
def external_commands
paths.map { |p| Dir["#{p}/brew-*"] }.flatten.
paths.flat_map { |p| Dir["#{p}/brew-*"] }.
map { |f| File.basename(f, ".rb")[5..-1] }.
reject { |f| f =~ /\./ }
end
......
......@@ -1220,7 +1220,7 @@ class Checks
end
def check_for_external_cmd_name_conflict
cmds = paths.map { |p| Dir["#{p}/brew-*"] }.flatten.uniq
cmds = paths.flat_map { |p| Dir["#{p}/brew-*"] }.uniq
cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) }
cmd_map = {}
cmds.each do |cmd|
......
......@@ -68,8 +68,8 @@ module Homebrew
dirs.delete "var"
args = dirs + %w[-type f (]
args.concat UNBREWED_EXCLUDE_FILES.map { |f| %W[! -name #{f}] }.flatten
args.concat UNBREWED_EXCLUDE_PATHS.map { |d| %W[! -path #{d}] }.flatten
args.concat UNBREWED_EXCLUDE_FILES.flat_map { |f| %W[! -name #{f}] }
args.concat UNBREWED_EXCLUDE_PATHS.flat_map { |d| %W[! -path #{d}] }
args.concat %w[)]
cd HOMEBREW_PREFIX
......
......@@ -124,7 +124,7 @@ class Dependency
all.map(&:name).uniq.map do |name|
deps = grouped.fetch(name)
dep = deps.first
tags = deps.map(&:tags).flatten.uniq
tags = deps.flat_map(&:tags).uniq
dep.class.new(name, tags, dep.env_proc)
end
end
......
......@@ -29,7 +29,7 @@ module SharedEnvExtension
def remove_cc_etc
keys = %w[CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS]
removed = Hash[*keys.map { |key| [key, self[key]] }.flatten]
removed = Hash[*keys.flat_map { |key| [key, self[key]] }]
keys.each do |key|
delete(key)
end
......
......@@ -757,12 +757,12 @@ class Formula
# an array of all tap {Formula} names
def self.tap_names
@tap_names ||= Tap.map(&:formula_names).flatten.sort
@tap_names ||= Tap.flat_map(&:formula_names).sort
end
# an array of all tap {Formula} files
def self.tap_files
@tap_files ||= Tap.map(&:formula_files).flatten
@tap_files ||= Tap.flat_map(&:formula_files)
end
# an array of all {Formula} names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment