favor flat_map over map...flatten
This commit is contained in:
parent
4e5227fd4e
commit
ae0e270727
@ -242,7 +242,7 @@ class FormulaAuditor
|
|||||||
if @online
|
if @online
|
||||||
same_name_tap_formulae += @@remote_official_taps.map do |tap|
|
same_name_tap_formulae += @@remote_official_taps.map do |tap|
|
||||||
Thread.new { Homebrew.search_tap "homebrew", tap, name }
|
Thread.new { Homebrew.search_tap "homebrew", tap, name }
|
||||||
end.map(&:value).flatten
|
end.flat_map(&:value)
|
||||||
end
|
end
|
||||||
|
|
||||||
same_name_tap_formulae.delete(full_name)
|
same_name_tap_formulae.delete(full_name)
|
||||||
|
@ -26,7 +26,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def external_commands
|
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] }.
|
map { |f| File.basename(f, ".rb")[5..-1] }.
|
||||||
reject { |f| f =~ /\./ }
|
reject { |f| f =~ /\./ }
|
||||||
end
|
end
|
||||||
|
@ -1220,7 +1220,7 @@ class Checks
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_for_external_cmd_name_conflict
|
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) }
|
cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) }
|
||||||
cmd_map = {}
|
cmd_map = {}
|
||||||
cmds.each do |cmd|
|
cmds.each do |cmd|
|
||||||
|
@ -68,8 +68,8 @@ module Homebrew
|
|||||||
dirs.delete "var"
|
dirs.delete "var"
|
||||||
|
|
||||||
args = dirs + %w[-type f (]
|
args = dirs + %w[-type f (]
|
||||||
args.concat UNBREWED_EXCLUDE_FILES.map { |f| %W[! -name #{f}] }.flatten
|
args.concat UNBREWED_EXCLUDE_FILES.flat_map { |f| %W[! -name #{f}] }
|
||||||
args.concat UNBREWED_EXCLUDE_PATHS.map { |d| %W[! -path #{d}] }.flatten
|
args.concat UNBREWED_EXCLUDE_PATHS.flat_map { |d| %W[! -path #{d}] }
|
||||||
args.concat %w[)]
|
args.concat %w[)]
|
||||||
|
|
||||||
cd HOMEBREW_PREFIX
|
cd HOMEBREW_PREFIX
|
||||||
|
@ -124,7 +124,7 @@ class Dependency
|
|||||||
all.map(&:name).uniq.map do |name|
|
all.map(&:name).uniq.map do |name|
|
||||||
deps = grouped.fetch(name)
|
deps = grouped.fetch(name)
|
||||||
dep = deps.first
|
dep = deps.first
|
||||||
tags = deps.map(&:tags).flatten.uniq
|
tags = deps.flat_map(&:tags).uniq
|
||||||
dep.class.new(name, tags, dep.env_proc)
|
dep.class.new(name, tags, dep.env_proc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,7 @@ module SharedEnvExtension
|
|||||||
|
|
||||||
def remove_cc_etc
|
def remove_cc_etc
|
||||||
keys = %w[CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS]
|
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|
|
keys.each do |key|
|
||||||
delete(key)
|
delete(key)
|
||||||
end
|
end
|
||||||
|
@ -757,12 +757,12 @@ class Formula
|
|||||||
|
|
||||||
# an array of all tap {Formula} names
|
# an array of all tap {Formula} names
|
||||||
def self.tap_names
|
def self.tap_names
|
||||||
@tap_names ||= Tap.map(&:formula_names).flatten.sort
|
@tap_names ||= Tap.flat_map(&:formula_names).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all tap {Formula} files
|
# an array of all tap {Formula} files
|
||||||
def self.tap_files
|
def self.tap_files
|
||||||
@tap_files ||= Tap.map(&:formula_files).flatten
|
@tap_files ||= Tap.flat_map(&:formula_files)
|
||||||
end
|
end
|
||||||
|
|
||||||
# an array of all {Formula} names
|
# an array of all {Formula} names
|
||||||
|
Loading…
x
Reference in New Issue
Block a user