That block is a thorn in my side from the beginning.
Pavol Vaskovic
12

How about:

if !filters.isEmpty {

included = Set(filters)

} else if onlyPrecommit {

included = Set(precommitTests.keys)

} else {

included = Set(allTests.map { $0.key })

}

That is 7 lines of code. One thing I don’t like about it is that the “included =” has to be repeated. The ternary operator elegantly requires that only once.

You can avoid that with an immediately called closure, but that adds 2 more lines:

inlcuded = {

if !filters.isEmpty {

return Set(filters)

} else if onlyPrecommit {

return Set(precommitTests.keys)

} else {

return Set(allTests.map { $0.key })

}

}()

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.