Use `flat_map` instead of flatten in some cases

parent 0778a2aa
......@@ -219,8 +219,8 @@ module Pod
# generated as result of the analyzer.
#
def pod_targets
aggregate_target_pod_targets = aggregate_targets.map(&:pod_targets).flatten
test_dependent_targets = aggregate_target_pod_targets.map(&:test_dependent_targets).flatten
aggregate_target_pod_targets = aggregate_targets.flat_map(&:pod_targets)
test_dependent_targets = aggregate_target_pod_targets.flat_map(&:test_dependent_targets)
(aggregate_target_pod_targets + test_dependent_targets).uniq
end
......
......@@ -340,7 +340,7 @@ module Pod
end
unless embedded_targets_missing_hosts.empty?
embedded_targets_missing_hosts_product_types = Set.new embedded_targets_missing_hosts.map(&:user_targets).flatten.map(&:symbol_type)
embedded_targets_missing_hosts_product_types = Set.new embedded_targets_missing_hosts.flat_map(&:user_targets).map(&:symbol_type)
target_names = embedded_targets_missing_hosts.map do |target|
target.name.sub('Pods-', '') # Make the target names more recognizable to the user
end.join ', '
......
......@@ -182,7 +182,7 @@ module Pod
# specs platform combinations.
#
def file_accessors
@file_accessors ||= pod_targets.map(&:file_accessors).flatten.compact
@file_accessors ||= pod_targets.flat_map(&:file_accessors).compact
end
# Adds file references to the list of the paths returned by the file
......
......@@ -75,8 +75,8 @@ module Pod
input_paths = []
output_paths = []
unless framework_paths.empty?
input_paths = [script_path, *framework_paths.map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.flatten.compact]
output_paths = framework_paths.map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.flatten.compact
input_paths = [script_path, *framework_paths.flat_map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.compact]
output_paths = framework_paths.flat_map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.compact
end
UserProjectIntegrator::TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
UserProjectIntegrator::TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths, output_paths)
......@@ -95,7 +95,7 @@ module Pod
# @return [Array<Hash<Symbol=>String>] an array of all combined script phases from the specs.
#
def script_phases_for_specs(specs)
specs.map { |spec| spec.consumer(target.platform) }.map(&:script_phases).flatten
specs.flat_map { |spec| spec.consumer(target.platform).script_phases }
end
end
end
......
......@@ -196,9 +196,9 @@ module Pod
# shipped with the Pod.
#
def vendored_frameworks_headers
vendored_frameworks.map do |framework|
vendored_frameworks.flat_map do |framework|
self.class.vendored_frameworks_headers(framework)
end.flatten.uniq
end.uniq
end
# @return [Array<Pathname>] The paths of the library bundles that come
......
......@@ -162,7 +162,7 @@ module Pod
# @return [Array<Specification>] The specifications used by this aggregate target.
#
def specs
pod_targets.map(&:specs).flatten
pod_targets.flat_map(&:specs)
end
# @return [Hash{Symbol => Array<Specification>}] The pod targets for each
......
......@@ -28,7 +28,7 @@ module Pod
result = @analyzer.analyze
aggregate_targets = result.targets
pod_targets = aggregate_targets.map(&:pod_targets).flatten.uniq
pod_targets = aggregate_targets.flat_map(&:pod_targets).uniq
sandbox.create_file_accessors(pod_targets)
TargetValidator.new(aggregate_targets, pod_targets)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment