mirror of https://github.com/sbt/sbt.git
I'd like to remove '---' and 'pair' in sbt 2 so I'm inlining the logic where
I find it. The '---' method is trivially implemented with a filter on
the sequence of files and filtering the output will not require io,
unlike '---'. For pair, I get confused every time I see it in the code
and it is rarely saving more than a line. While I understand that it may
have been convenient when the code using pair was originally written, I
don't think it is worth the maintenance cost. My specific issue is that
to me pair means tuple2, full stop. The definition of pair is:
def pair[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File, T)]
First of all, it's not at all obvious when seen inline in the code that
it has the side effect of evaluating PathFinder.get. Moreover, it
doesn't return a general pair, it's a very specific pair with a File in
the first position. I just don't see how using pair improves upon, say:
val func: File => Option[(File, String)] = ???
globs.all.flatMap(func)
or
val func: File => Option[(File, String)] = ???
globs.all.map(f => func(f) match {
case Some(r) => r
case None => throw new IllegalStateException("Couldn't evaluate func for $f")
}) // or just define `func = File => (File, String)` and throw on an error
|
||
|---|---|---|
| .. | ||
| ContrabandConfig.scala | ||
| Dependencies.scala | ||
| Docs.scala | ||
| NightlyPlugin.scala | ||
| PublishBinPlugin.scala | ||
| Release.scala | ||
| SbtLauncherPlugin.scala | ||
| Scripted.scala | ||
| StatusPlugin.scala | ||
| Sxr.scala | ||
| Transform.scala | ||
| Util.scala | ||
| build.properties | ||
| flamegraph_svg.png | ||
| plugins.sbt | ||