Commit 18221f95 authored by Dan Davison's avatar Dan Davison

Merge branch 'pl-flat_map-qa' into 'master'

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

See merge request gitlab-org/gitlab-ce!30883
parents 5595c9de 510d03fe
......@@ -181,11 +181,11 @@ module QA
return ["Page class does not have views / elements defined!"]
end
views.map(&:errors).flatten
views.flat_map(&:errors)
end
def self.elements
views.map(&:elements).flatten
views.flat_map(&:elements)
end
def send_keys_to_element(name, keys)
......
......@@ -22,16 +22,14 @@ module QA
end
def descendants
@descendants ||= constants.map do |const|
@descendants ||= constants.flat_map do |const|
case const
when Class
const if const < Page::Base
when Module
Page::Validator.new(const).descendants
end
end
@descendants.flatten.compact
end.compact
end
def errors
......
......@@ -14,7 +14,7 @@ module QA
Page::Validator.new(pages)
end
validators.map(&:errors).flatten.tap do |errors|
validators.flat_map(&:errors).tap do |errors|
break if errors.none?
warn <<~EOS
......
......@@ -125,9 +125,9 @@ describe QA::Specs::Runner do
end
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}"]
end.flatten
end
end
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