diff --git a/util/collection/src/main/scala/sbt/PMap.scala b/util/collection/src/main/scala/sbt/PMap.scala index 51c942112..cf0454fd9 100644 --- a/util/collection/src/main/scala/sbt/PMap.scala +++ b/util/collection/src/main/scala/sbt/PMap.scala @@ -52,7 +52,7 @@ object IMap { put(k, f(this get k getOrElse init)) def mapValues[V2[_]](f: V ~> V2) = - new IMap0[K, V2](backing.mapValues(x => f(x)).toMap) + new IMap0[K, V2](backing.mapValues(x => f(x))) def mapSeparate[VL[_], VR[_]](f: V ~> ({ type l[T] = Either[VL[T], VR[T]] })#l) = { diff --git a/util/collection/src/main/scala/sbt/Settings.scala b/util/collection/src/main/scala/sbt/Settings.scala index 4266af1b6..03173d6ce 100644 --- a/util/collection/src/main/scala/sbt/Settings.scala +++ b/util/collection/src/main/scala/sbt/Settings.scala @@ -17,9 +17,9 @@ sealed trait Settings[Scope] { } private final class Settings0[Scope](val data: Map[Scope, AttributeMap], val delegates: Scope => Seq[Scope]) extends Settings[Scope] { - def scopes: Set[Scope] = data.keySet.toSet + def scopes: Set[Scope] = data.keySet def keys(scope: Scope) = data(scope).keys.toSet - def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) } toSeq; + def allKeys[T](f: (Scope, AttributeKey[_]) => T): Seq[T] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) } toSeq def get[T](scope: Scope, key: AttributeKey[T]): Option[T] = delegates(scope).toStream.flatMap(sc => getDirect(sc, key)).headOption @@ -296,7 +296,7 @@ trait Init[Scope] { def definedAtString(settings: Seq[Setting[_]]): String = { val posDefined = settings.flatMap(_.positionString.toList) - if (posDefined.size > 0) { + if (posDefined.nonEmpty) { val header = if (posDefined.size == settings.size) "defined at:" else "some of the defining occurrences:" header + (posDefined.distinct mkString ("\n\t", "\n\t", "\n")) diff --git a/util/complete/src/main/scala/sbt/LineReader.scala b/util/complete/src/main/scala/sbt/LineReader.scala index 8f9fc219f..b85190f92 100644 --- a/util/complete/src/main/scala/sbt/LineReader.scala +++ b/util/complete/src/main/scala/sbt/LineReader.scala @@ -45,7 +45,7 @@ abstract class JLine extends LineReader { private[this] def handleMultilinePrompt(prompt: String): String = { val lines = """\r?\n""".r.split(prompt) - lines.size match { + lines.length match { case 0 | 1 => prompt case _ => reader.print(lines.init.mkString("\n") + "\n"); lines.last; } diff --git a/util/log/src/main/scala/sbt/LoggerWriter.scala b/util/log/src/main/scala/sbt/LoggerWriter.scala index 0165676f5..bc6062563 100644 --- a/util/log/src/main/scala/sbt/LoggerWriter.scala +++ b/util/log/src/main/scala/sbt/LoggerWriter.scala @@ -17,7 +17,7 @@ class LoggerWriter(delegate: Logger, unbufferedLevel: Option[Level.Value], nl: S override def close() = flush() override def flush(): Unit = synchronized { - if (buffer.length > 0) { + if (buffer.nonEmpty) { log(buffer.toString) buffer.clear() } diff --git a/util/relation/src/main/scala/sbt/Relation.scala b/util/relation/src/main/scala/sbt/Relation.scala index 987aafb14..9a648ad64 100644 --- a/util/relation/src/main/scala/sbt/Relation.scala +++ b/util/relation/src/main/scala/sbt/Relation.scala @@ -123,7 +123,7 @@ private final class MRelation[A, B](fwd: Map[A, Set[B]], rev: Map[B, Set[A]]) ex def _1s = fwd.keySet def _2s = rev.keySet - def size = (fwd.valuesIterator map { _.size }).foldLeft(0)(_ + _) + def size = (fwd.valuesIterator map (_.size)).sum def all: Traversable[(A, B)] = fwd.iterator.flatMap { case (a, bs) => bs.iterator.map(b => (a, b)) }.toTraversable