Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit f41dc2f

Browse files
committed
Get rid of FlatMap
1 parent 00c82a8 commit f41dc2f

File tree

10 files changed

+14
-27
lines changed

10 files changed

+14
-27
lines changed

lib/rspec/core.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
warnings
1313

1414
set
15-
flat_map
1615
filter_manager
1716
dsl
1817
notifications

lib/rspec/core/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ def run_suite_hooks(hook_description, hooks)
21542154
end
21552155

21562156
def get_files_to_run(paths)
2157-
files = FlatMap.flat_map(paths_to_check(paths)) do |path|
2157+
files = paths_to_check(paths).flat_map do |path|
21582158
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
21592159
File.directory?(path) ? gather_directories(path) : extract_location(path)
21602160
end.uniq

lib/rspec/core/configuration_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def parse_args_ignoring_files_or_dirs_to_run(args, source)
169169
def args_from_options_file(path)
170170
return [] unless path && File.exist?(path)
171171
config_string = options_file_as_erb_string(path)
172-
FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit)
172+
config_string.split(/\n+/).flat_map(&:shellsplit)
173173
end
174174

175175
def options_file_as_erb_string(path)

lib/rspec/core/example_group.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def self.filtered_examples
459459
# @private
460460
def self.descendant_filtered_examples
461461
@descendant_filtered_examples ||= filtered_examples +
462-
FlatMap.flat_map(children, &:descendant_filtered_examples)
462+
children.flat_map(&:descendant_filtered_examples)
463463
end
464464

465465
# @private
@@ -501,7 +501,7 @@ def self.next_runnable_index_for(file)
501501

502502
# @private
503503
def self.descendants
504-
@_descendants ||= [self] + FlatMap.flat_map(children, &:descendants)
504+
@_descendants ||= [self] + children.flat_map(&:descendants)
505505
end
506506

507507
## @private
@@ -646,7 +646,7 @@ def self.for_filtered_examples(reporter, &block)
646646
def self.declaration_locations
647647
@declaration_locations ||= [Metadata.location_tuple_from(metadata)] +
648648
examples.map { |e| Metadata.location_tuple_from(e.metadata) } +
649-
FlatMap.flat_map(children, &:declaration_locations)
649+
children.flat_map(&:declaration_locations)
650650
end
651651

652652
# @return [String] the unique id of this example group. Pass

lib/rspec/core/flat_map.rb

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/rspec/core/formatters/exception_presenter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def sub_failure_list_formatter(exception, message_color)
334334
common_backtrace_truncater = CommonBacktraceTruncater.new(exception)
335335

336336
lambda do |failure_number, colorizer|
337-
FlatMap.flat_map(exception.all_exceptions.each_with_index) do |failure, index|
337+
exception.all_exceptions.each_with_index.flat_map do |failure, index|
338338
options = with_multiple_error_options_as_needed(
339339
failure,
340340
:description => nil,

lib/rspec/core/formatters/snippet_extractor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def line_range_of_expression
7070
end
7171

7272
def unclosed_tokens_in_line_range(line_range)
73-
tokens = FlatMap.flat_map(line_range) do |line_number|
73+
tokens = line_range.flat_map do |line_number|
7474
source.tokens_by_line_number[line_number]
7575
end
7676

lib/rspec/core/hooks.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ def process(host, parent_groups, globals, position, scope)
564564
hooks_to_process = globals.processable_hooks_for(position, scope, host)
565565
return if hooks_to_process.empty?
566566

567-
hooks_to_process -= FlatMap.flat_map(parent_groups) do |group|
567+
hooks_to_process -= parent_groups.flat_map do |group|
568568
group.hooks.all_hooks_for(position, scope)
569569
end
570570
return if hooks_to_process.empty?
@@ -609,7 +609,7 @@ def run_example_hooks_for(example, position, each_method)
609609
end
610610

611611
def run_around_example_hooks_for(example)
612-
hooks = FlatMap.flat_map(owner_parent_groups) do |group|
612+
hooks = owner_parent_groups.flat_map do |group|
613613
group.hooks.matching_hooks_for(:around, :example, example)
614614
end
615615

lib/rspec/core/world.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,18 @@ def exclusion_filter
9999
#
100100
# Get count of examples to be run.
101101
def example_count(groups=example_groups)
102-
FlatMap.flat_map(groups) { |g| g.descendants }.
102+
groups.flat_map { |g| g.descendants }.
103103
inject(0) { |a, e| a + e.filtered_examples.size }
104104
end
105105

106106
# @private
107107
def all_example_groups
108-
FlatMap.flat_map(example_groups) { |g| g.descendants }
108+
example_groups.flat_map { |g| g.descendants }
109109
end
110110

111111
# @private
112112
def all_examples
113-
FlatMap.flat_map(all_example_groups) { |g| g.examples }
113+
all_example_groups.flat_map { |g| g.examples }
114114
end
115115

116116
# @private
@@ -223,7 +223,7 @@ def announce_exclusion_filter(announcements)
223223

224224
def descending_declaration_line_numbers_by_file
225225
@descending_declaration_line_numbers_by_file ||= begin
226-
declaration_locations = FlatMap.flat_map(example_groups, &:declaration_locations)
226+
declaration_locations = example_groups.flat_map(&:declaration_locations)
227227

228228
declarations_by_file = declaration_locations.group_by(&:first) # by file name
229229

spec/rspec/core/configuration_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ def exclude?(line)
19821982
registered_examples = nil
19831983

19841984
RSpec.configuration.define_derived_metadata(:ex) do |_meta|
1985-
registered_examples = FlatMap.flat_map(RSpec.world.all_example_groups, &:examples)
1985+
registered_examples = RSpec.world.all_example_groups.flat_map(&:examples)
19861986
end
19871987

19881988
example = nil

0 commit comments

Comments
 (0)