Commit 510d03fe authored by Peter Leitzen's avatar Peter Leitzen Committed by Dan Davison

QA: Prefer `flat_map` over `map` + `flatten`

parent 5595c9de
...@@ -181,11 +181,11 @@ module QA ...@@ -181,11 +181,11 @@ module QA
return ["Page class does not have views / elements defined!"] return ["Page class does not have views / elements defined!"]
end end
views.map(&:errors).flatten views.flat_map(&:errors)
end end
def self.elements def self.elements
views.map(&:elements).flatten views.flat_map(&:elements)
end end
def send_keys_to_element(name, keys) def send_keys_to_element(name, keys)
......
...@@ -22,16 +22,14 @@ module QA ...@@ -22,16 +22,14 @@ module QA
end end
def descendants def descendants
@descendants ||= constants.map do |const| @descendants ||= constants.flat_map do |const|
case const case const
when Class when Class
const if const < Page::Base const if const < Page::Base
when Module when Module
Page::Validator.new(const).descendants Page::Validator.new(const).descendants
end end
end end.compact
@descendants.flatten.compact
end end
def errors def errors
......
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
Page::Validator.new(pages) Page::Validator.new(pages)
end end
validators.map(&:errors).flatten.tap do |errors| validators.flat_map(&:errors).tap do |errors|
break if errors.none? break if errors.none?
warn <<~EOS warn <<~EOS
......
...@@ -125,9 +125,9 @@ describe QA::Specs::Runner do ...@@ -125,9 +125,9 @@ describe QA::Specs::Runner do
end end
def excluded_feature_tags_except(tag) def excluded_feature_tags_except(tag)
QA::Runtime::Env.supported_features.except(tag).map do |tag, _| QA::Runtime::Env.supported_features.except(tag).flat_map do |tag, _|
['--tag', "~requires_#{tag}"] ['--tag', "~requires_#{tag}"]
end.flatten end
end end
def expect_rspec_runner_arguments(arguments) def expect_rspec_runner_arguments(arguments)
......
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