From b3001e4c8004434a4729476c760562dd379f2a2b Mon Sep 17 00:00:00 2001
From: xuwei-k <6b656e6a69@gmail.com>
Date: Mon, 26 Jun 2023 06:55:49 +0900
Subject: [PATCH] update scalafmt
---
.scalafmt.conf | 10 +-
.../sbt/internal/io/MacOSXWatchService.scala | 19 +--
io/src/main/scala/sbt/internal/io/Milli.scala | 27 ++--
.../internal/io/SourceModificationWatch.scala | 6 +-
.../scala/sbt/internal/nio/FileCache.scala | 45 ++++---
.../scala/sbt/internal/nio/FileEvent.scala | 4 +-
.../internal/nio/FileTreeRepositoryImpl.scala | 19 +--
.../main/scala/sbt/internal/nio/Globs.scala | 6 +-
.../nio/WatchServiceBackedObservable.scala | 5 +-
io/src/main/scala/sbt/io/Hash.scala | 14 +--
io/src/main/scala/sbt/io/IO.scala | 119 +++++++++---------
io/src/main/scala/sbt/io/NameFilter.scala | 4 +-
io/src/main/scala/sbt/io/Path.scala | 42 +++----
io/src/main/scala/sbt/io/PathMapper.scala | 9 +-
io/src/main/scala/sbt/io/Using.scala | 25 ++--
.../scala/sbt/nio/file/FileAttributes.scala | 6 +-
.../scala/sbt/nio/file/FileTreeView.scala | 27 ++--
io/src/main/scala/sbt/nio/file/Glob.scala | 6 +-
.../scala/sbt/internal/io/RetrySpec.scala | 13 +-
.../io/SourceModificationWatchSpec.scala | 12 +-
.../internal/nio/MacOSXWatchServiceSpec.scala | 3 +-
.../sbt/internal/nio/PathSyntaxSpec.scala | 2 +-
io/src/test/scala/sbt/io/CopySpec.scala | 19 ++-
.../test/scala/sbt/io/LastModifiedSpec.scala | 4 +-
.../sbt/io/NameFilterSpecification.scala | 10 +-
io/src/test/scala/sbt/io/PathMapperSpec.scala | 4 +-
.../test/scala/sbt/nio/PathFilterSpec.scala | 4 +-
project/HouseRulesPluglin.scala | 4 +-
28 files changed, 237 insertions(+), 231 deletions(-)
diff --git a/.scalafmt.conf b/.scalafmt.conf
index d5b09d7c..4bcacf16 100644
--- a/.scalafmt.conf
+++ b/.scalafmt.conf
@@ -1,12 +1,12 @@
-version = 2.0.0
+version = 3.7.4
maxColumn = 100
project.git = true
project.excludeFilters = [ /sbt-test/, /input_sources/, /contraband-scala/ ]
-lineEndings = preserve
# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
-docstrings = JavaDoc
+docstrings.style = Asterisk
+docstrings.wrap = no
# This also seems more idiomatic to include whitespace in import x.{ yyy }
spaces.inImportCurlyBraces = true
@@ -17,6 +17,8 @@ align.openParenCallSite = false
align.openParenDefnSite = false
# For better code clarity
-danglingParentheses = true
+danglingParentheses.preset = true
trailingCommas = preserve
+
+runner.dialect = Scala212Source3
diff --git a/io/src/main/scala/sbt/internal/io/MacOSXWatchService.scala b/io/src/main/scala/sbt/internal/io/MacOSXWatchService.scala
index bbeabc67..c70e77cb 100644
--- a/io/src/main/scala/sbt/internal/io/MacOSXWatchService.scala
+++ b/io/src/main/scala/sbt/internal/io/MacOSXWatchService.scala
@@ -83,15 +83,16 @@ private[sbt] class MacOSXWatchService extends WatchService with Unregisterable {
val parent = path.getParent
if (!keys.contains(parent)) {
// workaround for https://github.com/sbt/sbt/issues/4603
- if (keys.keys.exists(
- p =>
- p.getParent == parent && {
- val leftFileName = p.getFileName.toString
- val rightFileName = path.getFileName.toString
- leftFileName != rightFileName && (leftFileName
- .startsWith(rightFileName) || rightFileName.startsWith(leftFileName))
- }
- )) {
+ if (
+ keys.keys.exists(p =>
+ p.getParent == parent && {
+ val leftFileName = p.getFileName.toString
+ val rightFileName = path.getFileName.toString
+ leftFileName != rightFileName && (leftFileName
+ .startsWith(rightFileName) || rightFileName.startsWith(leftFileName))
+ }
+ )
+ ) {
parentKeys.put(parent, underlying.register(parent, events: _*))
}
}
diff --git a/io/src/main/scala/sbt/internal/io/Milli.scala b/io/src/main/scala/sbt/internal/io/Milli.scala
index fe2e4750..2db61d96 100644
--- a/io/src/main/scala/sbt/internal/io/Milli.scala
+++ b/io/src/main/scala/sbt/internal/io/Milli.scala
@@ -303,19 +303,20 @@ private object WinMilli extends MilliNative[FILETIME] {
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
)
- val mtime = try {
- val modifiedTime = new FILETIME.ByReference()
- if (!GetFileTime(hFile, /*creationTime*/ null, /*accessTime*/ null, modifiedTime))
- throw new IOException(
- "GetFileTime() failed with error " + GetLastError() + " for file " + filePath
- )
- modifiedTime
- } finally {
- if (!CloseHandle(hFile))
- throw new IOException(
- "CloseHandle() after GetFileTime() failed with error " + GetLastError() + " for file " + filePath
- )
- }
+ val mtime =
+ try {
+ val modifiedTime = new FILETIME.ByReference()
+ if (!GetFileTime(hFile, /*creationTime*/ null, /*accessTime*/ null, modifiedTime))
+ throw new IOException(
+ "GetFileTime() failed with error " + GetLastError() + " for file " + filePath
+ )
+ modifiedTime
+ } finally {
+ if (!CloseHandle(hFile))
+ throw new IOException(
+ "CloseHandle() after GetFileTime() failed with error " + GetLastError() + " for file " + filePath
+ )
+ }
mtime
}
diff --git a/io/src/main/scala/sbt/internal/io/SourceModificationWatch.scala b/io/src/main/scala/sbt/internal/io/SourceModificationWatch.scala
index d17860b0..c6312f6d 100644
--- a/io/src/main/scala/sbt/internal/io/SourceModificationWatch.scala
+++ b/io/src/main/scala/sbt/internal/io/SourceModificationWatch.scala
@@ -117,8 +117,8 @@ private[sbt] final class WatchState private (
/** Retrieve events from the `WatchService` */
private[sbt] def pollEvents(): Iterable[(Path, WatchEvent[_])] = {
val events = service.pollEvents()
- events.toIterable.flatMap {
- case (k, evs) => evs.map((k.watchable().asInstanceOf[Path], _))
+ events.toIterable.flatMap { case (k, evs) =>
+ evs.map((k.watchable().asInstanceOf[Path], _))
}
}
@@ -235,7 +235,7 @@ final class Source(
override def equals(o: Any): Boolean = o match {
case that: Source =>
this.base == that.base && this.includeFilter == that.includeFilter &&
- this.excludeFilter == that.excludeFilter && this.recursive == that.recursive
+ this.excludeFilter == that.excludeFilter && this.recursive == that.recursive
case _ => false
}
override lazy val hashCode: Int = Seq[Any](base, includeFilter, excludeFilter, recursive).hashCode
diff --git a/io/src/main/scala/sbt/internal/nio/FileCache.scala b/io/src/main/scala/sbt/internal/nio/FileCache.scala
index 06effac1..2a42245a 100644
--- a/io/src/main/scala/sbt/internal/nio/FileCache.scala
+++ b/io/src/main/scala/sbt/internal/nio/FileCache.scala
@@ -63,21 +63,19 @@ private[nio] class FileCache[+T](converter: Path => T, globs: mutable.Set[Glob])
FileAttributes(path).foreach(add(glob, _))
val current = subMap.asScala.toMap
val result = new util.ArrayList[FileEvent[T]].asScala
- previous.foreach {
- case (p, prev) =>
- current.get(p) match {
- case Some(newPair) if prev != newPair =>
- result += Update(p, prev, newPair)
- case None => result += Deletion(p, prev)
- case _ =>
- }
+ previous.foreach { case (p, prev) =>
+ current.get(p) match {
+ case Some(newPair) if prev != newPair =>
+ result += Update(p, prev, newPair)
+ case None => result += Deletion(p, prev)
+ case _ =>
+ }
}
- current.foreach {
- case (p, newAttributes) =>
- previous.get(p) match {
- case None => result += Creation(p, newAttributes)
- case _ =>
- }
+ current.foreach { case (p, newAttributes) =>
+ previous.get(p) match {
+ case None => result += Creation(p, newAttributes)
+ case _ =>
+ }
}
result.toVector
} else {
@@ -132,16 +130,15 @@ private[nio] class FileCache[+T](converter: Path => T, globs: mutable.Set[Glob])
}
private[this] def updateGlob(path: Path): Glob = {
val depth = globs.toIndexedSeq.view
- .map(
- g =>
- if (path.startsWith(g.base)) {
- if (path == g.base) g.range._2
- else
- g.range._2 match {
- case Int.MaxValue => Int.MaxValue
- case d => d - g.base.relativize(path).getNameCount
- }
- } else Int.MinValue
+ .map(g =>
+ if (path.startsWith(g.base)) {
+ if (path == g.base) g.range._2
+ else
+ g.range._2 match {
+ case Int.MaxValue => Int.MaxValue
+ case d => d - g.base.relativize(path).getNameCount
+ }
+ } else Int.MinValue
)
.min
depth match {
diff --git a/io/src/main/scala/sbt/internal/nio/FileEvent.scala b/io/src/main/scala/sbt/internal/nio/FileEvent.scala
index f2bf5c2f..e20598e6 100644
--- a/io/src/main/scala/sbt/internal/nio/FileEvent.scala
+++ b/io/src/main/scala/sbt/internal/nio/FileEvent.scala
@@ -52,8 +52,8 @@ private[sbt] object FileEvent {
override def exists: Boolean = true
}
private[sbt] object Update {
- def apply[T](path: Path, previousAttributes: T, attributes: T)(
- implicit timeSource: TimeSource
+ def apply[T](path: Path, previousAttributes: T, attributes: T)(implicit
+ timeSource: TimeSource
): Update[T] =
new Update(path, previousAttributes, attributes) {
override val occurredAt: Deadline = timeSource.now
diff --git a/io/src/main/scala/sbt/internal/nio/FileTreeRepositoryImpl.scala b/io/src/main/scala/sbt/internal/nio/FileTreeRepositoryImpl.scala
index 48950c91..0a86a959 100644
--- a/io/src/main/scala/sbt/internal/nio/FileTreeRepositoryImpl.scala
+++ b/io/src/main/scala/sbt/internal/nio/FileTreeRepositoryImpl.scala
@@ -115,15 +115,16 @@ private[sbt] class FileTreeRepositoryImpl[T] extends FileTreeRepository[FileAttr
// workaround for https://github.com/sbt/sbt/issues/4603
val parent = glob.base.getParent
if (!registered.contains(parent)) {
- if (registered.exists(
- path =>
- path.getParent == parent && {
- val leftFileName = path.getFileName.toString
- val rightFileName = base.getFileName.toString
- leftFileName != rightFileName && (leftFileName
- .startsWith(rightFileName) || rightFileName.startsWith(leftFileName))
- }
- )) {
+ if (
+ registered.exists(path =>
+ path.getParent == parent && {
+ val leftFileName = path.getFileName.toString
+ val rightFileName = base.getFileName.toString
+ leftFileName != rightFileName && (leftFileName
+ .startsWith(rightFileName) || rightFileName.startsWith(leftFileName))
+ }
+ )
+ ) {
register(Glob(parent))
}
}
diff --git a/io/src/main/scala/sbt/internal/nio/Globs.scala b/io/src/main/scala/sbt/internal/nio/Globs.scala
index b317bfde..0aebba91 100644
--- a/io/src/main/scala/sbt/internal/nio/Globs.scala
+++ b/io/src/main/scala/sbt/internal/nio/Globs.scala
@@ -48,8 +48,8 @@ private[sbt] object Globs {
case NothingFilter => Some(AnyPath)
case AllPassFilter => Some(NoPath)
case f =>
- fileFilterToRelativeGlob(f).collect {
- case m: Matcher => Matcher.not(m)
+ fileFilterToRelativeGlob(f).collect { case m: Matcher =>
+ Matcher.not(m)
}
}
case of: OrFilter =>
@@ -90,7 +90,7 @@ private[sbt] object Globs {
case ef: ExtensionFilter =>
ef.extensions match {
case extensions if extensions.length == 1 => Some(Matcher(s"*.${extensions.head}"))
- case extensions => Some(Matcher(s"*.${extensions.mkString("{", ",", "}")}"))
+ case extensions => Some(Matcher(s"*.${extensions.mkString("{", ",", "}")}"))
}
case NothingFilter => Some(NoPath)
case nf: NotNameFilter =>
diff --git a/io/src/main/scala/sbt/internal/nio/WatchServiceBackedObservable.scala b/io/src/main/scala/sbt/internal/nio/WatchServiceBackedObservable.scala
index 16a66389..5969178e 100644
--- a/io/src/main/scala/sbt/internal/nio/WatchServiceBackedObservable.scala
+++ b/io/src/main/scala/sbt/internal/nio/WatchServiceBackedObservable.scala
@@ -98,9 +98,8 @@ private[sbt] class WatchServiceBackedObservable(
(event match {
case Creation(path, attrs) if attrs.isDirectory =>
s.register(path)
- event +: view.list(Glob(path, RecursiveGlob)).flatMap {
- case (p, a) =>
- process(Creation(p, a))
+ event +: view.list(Glob(path, RecursiveGlob)).flatMap { case (p, a) =>
+ process(Creation(p, a))
}
case Deletion(p, attrs) if attrs.isDirectory =>
val events = fileCache.refresh(Glob(p, RecursiveGlob))
diff --git a/io/src/main/scala/sbt/io/Hash.scala b/io/src/main/scala/sbt/io/Hash.scala
index f1092029..a8bf125a 100644
--- a/io/src/main/scala/sbt/io/Hash.scala
+++ b/io/src/main/scala/sbt/io/Hash.scala
@@ -16,14 +16,14 @@ import java.net.{ URI, URL }
object Hash {
private val BufferSize = 8192
- /** Converts an array of `bytes` to a hexadecimal representation String.*/
+ /** Converts an array of `bytes` to a hexadecimal representation String. */
def toHex(bytes: Array[Byte]): String = {
val buffer = new StringBuilder(bytes.length * 2)
for (i <- bytes.indices) {
val b = bytes(i)
val bi: Int = if (b < 0) b + 256 else b.toInt
buffer append toHex((bi >>> 4).asInstanceOf[Byte])
- buffer append toHex((bi & 0x0F).asInstanceOf[Byte])
+ buffer append toHex((bi & 0x0f).asInstanceOf[Byte])
}
buffer.toString
}
@@ -52,18 +52,18 @@ object Hash {
/** Computes the SHA-1 hash of `s` and truncates the hexadecimal representation of the hash via [[halve]]. */
def halfHashString(s: String): String = halve(toHex(apply(s)))
- /** Calculates the SHA-1 hash of the given String.*/
+ /** Calculates the SHA-1 hash of the given String. */
def apply(s: String): Array[Byte] = apply(s.getBytes("UTF-8"))
- /** Calculates the SHA-1 hash of the given Array[Byte].*/
+ /** Calculates the SHA-1 hash of the given Array[Byte]. */
def apply(as: Array[Byte]): Array[Byte] = apply(new ByteArrayInputStream(as))
- /** Calculates the SHA-1 hash of the given file.*/
+ /** Calculates the SHA-1 hash of the given file. */
def apply(file: File): Array[Byte] =
try apply(new BufferedInputStream(new FileInputStream(file))) // apply closes the stream
catch { case _: FileNotFoundException => apply("") }
- /** Calculates the SHA-1 hash of the given resource.*/
+ /** Calculates the SHA-1 hash of the given resource. */
def apply(url: URL): Array[Byte] = Using.urlInputStream(url)(apply)
/**
@@ -74,7 +74,7 @@ object Hash {
def contentsIfLocal(uri: URI): Array[Byte] =
if (uri.getScheme == "file") apply(uri.toURL) else apply(uri.normalize.toString)
- /** Calculates the SHA-1 hash of the given stream, closing it when finished.*/
+ /** Calculates the SHA-1 hash of the given stream, closing it when finished. */
def apply(stream: InputStream): Array[Byte] = {
import java.security.{ DigestInputStream, MessageDigest }
val digest = MessageDigest.getInstance("SHA")
diff --git a/io/src/main/scala/sbt/io/IO.scala b/io/src/main/scala/sbt/io/IO.scala
index edb8ca46..5eb0e1f2 100644
--- a/io/src/main/scala/sbt/io/IO.scala
+++ b/io/src/main/scala/sbt/io/IO.scala
@@ -34,17 +34,17 @@ import scala.reflect.{ Manifest => SManifest }
import scala.util.control.Exception._
import scala.util.control.NonFatal
-/** A collection of File, URL, and I/O utility methods.*/
+/** A collection of File, URL, and I/O utility methods. */
object IO {
- /** The maximum number of times a unique temporary filename is attempted to be created.*/
+ /** The maximum number of times a unique temporary filename is attempted to be created. */
private val MaximumTries = 10
- /** The producer of randomness for unique name generation.*/
+ /** The producer of randomness for unique name generation. */
private lazy val random = new java.util.Random
val temporaryDirectory = new File(System.getProperty("java.io.tmpdir"))
- /** The size of the byte or char buffer used in various methods.*/
+ /** The size of the byte or char buffer used in various methods. */
private val BufferSize = 8192
/** File scheme name */
@@ -142,24 +142,23 @@ object IO {
try {
localcl
.orElse(syscl)
- .map(
- url =>
- url.getProtocol match {
- case "jar" =>
- val path = url.getPath
- val end = path.indexOf('!')
- new URI(
- if (end == -1) path
- else path.substring(0, end)
- ).toURL
- case "jrt" =>
- val path = url.getPath
- val end = path.indexOf('/', 1)
- new URI(
- s"jrt://${if (end == -1) path else path.substring(0, end)}"
- ).toURL
- case _ => url
- }
+ .map(url =>
+ url.getProtocol match {
+ case "jar" =>
+ val path = url.getPath
+ val end = path.indexOf('!')
+ new URI(
+ if (end == -1) path
+ else path.substring(0, end)
+ ).toURL
+ case "jrt" =>
+ val path = url.getPath
+ val end = path.indexOf('/', 1)
+ new URI(
+ s"jrt://${if (end == -1) path else path.substring(0, end)}"
+ ).toURL
+ case _ => url
+ }
)
.getOrElse(sys.error("No class location for " + cl))
} catch {
@@ -317,20 +316,21 @@ object IO {
sys.error("Could not update last modified time for file " + absFile)
}
- /** Creates directories `dirs` and all parent directories. It tries to work around a race condition in `File.mkdirs()` by retrying up to a limit.*/
+ /** Creates directories `dirs` and all parent directories. It tries to work around a race condition in `File.mkdirs()` by retrying up to a limit. */
def createDirectories(dirs: Traversable[File]): Unit =
dirs.foreach(createDirectory)
- /** Creates directory `dir` and all parent directories. It tries to work around a race condition in `File.mkdirs()` by retrying up to a limit.*/
+ /** Creates directory `dir` and all parent directories. It tries to work around a race condition in `File.mkdirs()` by retrying up to a limit. */
def createDirectory(dir: File): Unit = {
def failBase = "Could not create directory " + dir
// Need a retry because Files.createDirectories may fail before succeeding on (at least) windows.
val path = dir.toPath
- try Retry(
- try Files.createDirectories(path)
- catch { case _: IOException if Files.isDirectory(path) => },
- excludedExceptions = classOf[FileAlreadyExistsException]
- )
+ try
+ Retry(
+ try Files.createDirectories(path)
+ catch { case _: IOException if Files.isDirectory(path) => },
+ excludedExceptions = classOf[FileAlreadyExistsException]
+ )
catch { case e: IOException => throw new IOException(failBase + ": " + e, e) }
()
}
@@ -345,7 +345,7 @@ object IO {
}
}
- /** Gzips the InputStream 'in' and writes it to 'output'. Neither stream is closed.*/
+ /** Gzips the InputStream 'in' and writes it to 'output'. Neither stream is closed. */
def gzip(input: InputStream, output: OutputStream): Unit =
gzipOutputStream(output)(gzStream => transfer(input, gzStream))
@@ -359,7 +359,7 @@ object IO {
}
}
- /** Gunzips the InputStream 'input' and writes it to 'output'. Neither stream is closed.*/
+ /** Gunzips the InputStream 'input' and writes it to 'output'. Neither stream is closed. */
def gunzip(input: InputStream, output: OutputStream): Unit =
gzipInputStream(input)(gzStream => transfer(gzStream, output))
@@ -404,7 +404,7 @@ object IO {
val name = entry.getName
if (filter.accept(name)) {
val target = new File(toDirectory, name)
- //log.debug("Extracting zip entry '" + name + "' to '" + target + "'")
+ // log.debug("Extracting zip entry '" + name + "' to '" + target + "'")
if (entry.isDirectory)
createDirectory(target)
else {
@@ -416,7 +416,7 @@ object IO {
if (preserveLastModified)
setModifiedTimeOrFalse(target, entry.getTime)
} else {
- //log.debug("Ignoring zip entry '" + name + "'")
+ // log.debug("Ignoring zip entry '" + name + "'")
}
from.closeEntry()
next()
@@ -433,7 +433,7 @@ object IO {
// transfer(inputStream, to)
// }
- /** Copies the contents of `in` to `out`.*/
+ /** Copies the contents of `in` to `out`. */
def transfer(in: File, out: File): Unit =
fileInputStream(in)(in => transfer(in, out))
@@ -444,7 +444,7 @@ object IO {
def transfer(in: File, out: OutputStream): Unit =
fileInputStream(in)(in => transfer(in, out))
- /** Copies all bytes from the given input stream to the given File. The input stream is not closed by this method.*/
+ /** Copies all bytes from the given input stream to the given File. The input stream is not closed by this method. */
def transfer(in: InputStream, to: File): Unit =
Using.fileOutputStream()(to) { outputStream =>
transfer(in, outputStream)
@@ -552,16 +552,18 @@ object IO {
for ((f, true) <- isEmpty) f.delete
}
- /** Deletes each file or directory (recursively) in `files`.*/
+ /** Deletes each file or directory (recursively) in `files`. */
def delete(files: Iterable[File]): Unit = files.foreach(delete)
- /** Deletes each file or directory in `files` recursively. Any empty parent directories are deleted, recursively.*/
+ /** Deletes each file or directory in `files` recursively. Any empty parent directories are deleted, recursively. */
def deleteFilesEmptyDirs(files: Iterable[File]): Unit = {
def isEmptyDirectory(dir: File) = dir.isDirectory && listFiles(dir).isEmpty
def parents(fs: Set[File]) = fs flatMap (f => Option(f.getParentFile))
@tailrec def deleteEmpty(dirs: Set[File]): Unit = {
val empty = dirs filter isEmptyDirectory
- if (empty.nonEmpty) // looks funny, but this is true if at least one of `dirs` is an empty directory
+ if (
+ empty.nonEmpty
+ ) // looks funny, but this is true if at least one of `dirs` is an empty directory
{
empty foreach { _.delete() }
deleteEmpty(parents(empty))
@@ -592,15 +594,15 @@ object IO {
()
}
- /** Returns the children of directory `dir` that match `filter` in a non-null array.*/
+ /** Returns the children of directory `dir` that match `filter` in a non-null array. */
def listFiles(filter: java.io.FileFilter)(dir: File): Array[File] =
wrapNull(dir.listFiles(filter))
- /** Returns the children of directory `dir` that match `filter` in a non-null array.*/
+ /** Returns the children of directory `dir` that match `filter` in a non-null array. */
def listFiles(dir: File, filter: java.io.FileFilter): Array[File] =
wrapNull(dir.listFiles(filter))
- /** Returns the children of directory `dir` in a non-null array.*/
+ /** Returns the children of directory `dir` in a non-null array. */
def listFiles(dir: File): Array[File] = wrapNull(dir.listFiles())
private[sbt] def wrapNull(a: Array[File]) = if (a == null) new Array[File](0) else a
@@ -670,11 +672,11 @@ object IO {
createEntry: String => ZipEntry
) = {
val files = sources
- .flatMap {
- case (file, name) => if (file.isFile) (file, normalizeToSlash(name)) :: Nil else Nil
+ .flatMap { case (file, name) =>
+ if (file.isFile) (file, normalizeToSlash(name)) :: Nil else Nil
}
- .sortBy {
- case (_, name) => name
+ .sortBy { case (_, name) =>
+ name
}
val now = System.currentTimeMillis
@@ -708,10 +710,10 @@ object IO {
output.closeEntry()
}
- //Calculate directories and add them to the generated Zip
+ // Calculate directories and add them to the generated Zip
allDirectoryPaths(files) foreach addDirectoryEntry
- //Add all files to the generated Zip
+ // Add all files to the generated Zip
files foreach { case (file, name) => addFileEntry(file, name) }
}
@@ -795,7 +797,8 @@ object IO {
val basePath = toAbsolutePath(base).normalize
val filePath = toAbsolutePath(file).normalize
if (filePath startsWith basePath) {
- val relativePath = catching(classOf[IllegalArgumentException]) opt (basePath relativize filePath)
+ val relativePath =
+ catching(classOf[IllegalArgumentException]) opt (basePath relativize filePath)
relativePath map (_.toString)
} else None
}
@@ -962,7 +965,7 @@ object IO {
out.toString(charset.name)
}
- /** Reads the full contents of `in` into a byte array. This method does not close `in`.*/
+ /** Reads the full contents of `in` into a byte array. This method does not close `in`. */
def readStream(in: InputStream, charset: Charset = defaultCharset): String = {
val out = new ByteArrayOutputStream
transfer(in, out)
@@ -1011,11 +1014,11 @@ object IO {
def readLines(file: File, charset: Charset = defaultCharset): List[String] =
fileReader(charset)(file)(readLines)
- /** Reads all of the lines from `in`. This method does not close `in`.*/
+ /** Reads all of the lines from `in`. This method does not close `in`. */
def readLines(in: BufferedReader): List[String] =
foldLines[List[String]](in, Nil)((accum, line) => line :: accum).reverse
- /** Applies `f` to each line read from `in`. This method does not close `in`.*/
+ /** Applies `f` to each line read from `in`. This method does not close `in`. */
def foreachLine(in: BufferedReader)(f: String => Unit): Unit =
foldLines(in, ())((_, line) => f(line))
@@ -1059,12 +1062,12 @@ object IO {
def write(properties: Properties, label: String, to: File) =
fileOutputStream()(to)(output => properties.store(output, label))
- /** Reads the properties in `from` into `properties`. If `from` does not exist, `properties` is left unchanged.*/
+ /** Reads the properties in `from` into `properties`. If `from` does not exist, `properties` is left unchanged. */
def load(properties: Properties, from: File): Unit =
if (from.exists)
fileInputStream(from)(input => properties.load(input))
- /** A pattern used to split a String by path separator characters.*/
+ /** A pattern used to split a String by path separator characters. */
private val PathSeparatorPattern = java.util.regex.Pattern.compile(File.pathSeparator)
/** Splits a String around the platform's path separator characters. */
@@ -1157,7 +1160,7 @@ object IO {
* it does not already end with a slash.
*/
def directoryURI(uri: URI): URI = {
- if (!uri.isAbsolute) return uri; //assertAbsolute(uri)
+ if (!uri.isAbsolute) return uri; // assertAbsolute(uri)
val str = uri.toASCIIString
val dirURI =
if (str.endsWith("/") || uri.getScheme != FileScheme || (uri.getRawFragment ne null))
@@ -1171,7 +1174,7 @@ object IO {
private[sbt] val isWindows: Boolean =
System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")
- /** Converts the given File to a URI. If the File is relative, the URI is relative, unlike File.toURI*/
+ /** Converts the given File to a URI. If the File is relative, the URI is relative, unlike File.toURI */
def toURI(f: File): URI = {
def ensureHeadSlash(name: String) =
if (name.nonEmpty && name.head != File.separatorChar) s"${File.separatorChar}$name"
@@ -1187,8 +1190,8 @@ object IO {
new URI(FileScheme, "", normalizeToSlash(p), null)
}
} else if (f.isAbsolute) {
- //not using f.toURI to avoid filesystem syscalls
- //we use empty string as host to force file:// instead of just file:
+ // not using f.toURI to avoid filesystem syscalls
+ // we use empty string as host to force file:// instead of just file:
new URI(FileScheme, "", normalizeToSlash(ensureHeadSlash(f.getAbsolutePath)), null)
} else {
// need to use the three argument URI constructor because the single argument version doesn't encode
@@ -1210,7 +1213,7 @@ object IO {
def assertAbsolute(f: File) = assert(f.isAbsolute, "Not absolute: " + f)
def assertAbsolute(uri: URI) = assert(uri.isAbsolute, "Not absolute: " + uri)
- /** Parses a classpath String into File entries according to the current platform's path separator.*/
+ /** Parses a classpath String into File entries according to the current platform's path separator. */
def parseClasspath(s: String): Seq[File] =
if (s.isEmpty) Nil else IO.pathSplit(s).map(new File(_)).toSeq
diff --git a/io/src/main/scala/sbt/io/NameFilter.scala b/io/src/main/scala/sbt/io/NameFilter.scala
index 1a5ea69b..29e4f7f4 100644
--- a/io/src/main/scala/sbt/io/NameFilter.scala
+++ b/io/src/main/scala/sbt/io/NameFilter.scala
@@ -318,7 +318,7 @@ object NameFilter {
}
object FileFilter {
- /** Allows a String to be used where a `NameFilter` is expected and any asterisks (`*`) will be interpreted as wildcards. See [[sbt.io.GlobFilter]].*/
+ /** Allows a String to be used where a `NameFilter` is expected and any asterisks (`*`) will be interpreted as wildcards. See [[sbt.io.GlobFilter]]. */
implicit def globFilter(s: String): NameFilter = GlobFilter(s)
/**
@@ -385,7 +385,7 @@ object GlobFilter {
new ExtensionFilter(ext.drop(1))
case Array(prefix, "") => new PrefixFilter(prefix)
case Array("", suffix) => new SuffixFilter(suffix)
- case _ => new PatternFilter(parts, Pattern.compile(parts.map(quote).mkString(".*")))
+ case _ => new PatternFilter(parts, Pattern.compile(parts.map(quote).mkString(".*")))
}
}
}
diff --git a/io/src/main/scala/sbt/io/Path.scala b/io/src/main/scala/sbt/io/Path.scala
index b1d6c659..e6197c3c 100644
--- a/io/src/main/scala/sbt/io/Path.scala
+++ b/io/src/main/scala/sbt/io/Path.scala
@@ -33,13 +33,13 @@ import scala.collection.mutable
final class RichFile(val asFile: File) extends AnyVal with RichNioPath {
def /(component: String): File = if (component == ".") asFile else new File(asFile, component)
- /** True if and only if the wrapped file exists.*/
+ /** True if and only if the wrapped file exists. */
def exists: Boolean = asFile.exists
- /** True if and only if the wrapped file is a directory.*/
+ /** True if and only if the wrapped file is a directory. */
def isDirectory: Boolean = asFile.isDirectory
- /** The last modified time of the wrapped file.*/
+ /** The last modified time of the wrapped file. */
def lastModified: Long = IO.getModifiedTimeOrZero(asFile)
/**
@@ -54,12 +54,12 @@ final class RichFile(val asFile: File) extends AnyVal with RichNioPath {
*/
def olderThan(other: File): Boolean = Path.newerThan(other, asFile)
- /** The wrapped file converted to a URL
.*/
+ /** The wrapped file converted to a URL
. */
def asURL: URL = asFile.toURI.toURL
def absolutePath: String = asFile.getAbsolutePath
- /** The last component of this path.*/
+ /** The last component of this path. */
def name: String = asFile.getName
def baseAndExt: (String, String) = {
@@ -301,7 +301,7 @@ object Path extends Mapper {
def newerThan(a: File, b: File): Boolean =
a.exists && (!b.exists || IO.getModifiedTimeOrZero(a) > IO.getModifiedTimeOrZero(b))
- /** The separator character of the platform.*/
+ /** The separator character of the platform. */
val sep: Char = java.io.File.separatorChar
def toURLs(files: Seq[File]): Array[URL] = files.map(_.toURI.toURL).toArray
@@ -317,9 +317,8 @@ object Path extends Mapper {
(file, filter) =>
fileTreeView
.list(Glob(file.toPath, AnyPath))
- .flatMap {
- case (path: NioPath, attrs: FileAttributes) =>
- if (filter.accept(new AttributedFile(path, attrs))) Some(path.toFile) else None
+ .flatMap { case (path: NioPath, attrs: FileAttributes) =>
+ if (filter.accept(new AttributedFile(path, attrs))) Some(path.toFile) else None
}
} else { (file, filter) =>
IO.wrapNull(file.listFiles(filter)).toSeq
@@ -334,7 +333,7 @@ object Path extends Mapper {
object PathFinder {
- /** A PathFinder
that always produces the empty set of Path
s.*/
+ /** A PathFinder
that always produces the empty set of Path
s. */
val empty: PathFinder = new PathFinder {}
def apply(file: File): PathFinder = new SingleFile(file)
@@ -660,17 +659,18 @@ private object DescendantOrSelfPathFinder {
try {
if (filter.accept(file)) fileSet += file
if (depth > 0)
- FileTreeView.default.list(file.toPath).foreach {
- case (path, attributes) =>
- val file = path.toFile
- if (attributes.isRegularFile && filter.accept(new File(path.toString) {
- override def isDirectory: Boolean = attributes.isDirectory
- override def isFile: Boolean = attributes.isRegularFile
- })) {
- fileSet += file
- } else if (attributes.isDirectory) {
- native(file, filter, fileSet, depth - 1)
- }
+ FileTreeView.default.list(file.toPath).foreach { case (path, attributes) =>
+ val file = path.toFile
+ if (
+ attributes.isRegularFile && filter.accept(new File(path.toString) {
+ override def isDirectory: Boolean = attributes.isDirectory
+ override def isFile: Boolean = attributes.isRegularFile
+ })
+ ) {
+ fileSet += file
+ } else if (attributes.isDirectory) {
+ native(file, filter, fileSet, depth - 1)
+ }
}
()
} catch {
diff --git a/io/src/main/scala/sbt/io/PathMapper.scala b/io/src/main/scala/sbt/io/PathMapper.scala
index 25bbd964..265518bf 100644
--- a/io/src/main/scala/sbt/io/PathMapper.scala
+++ b/io/src/main/scala/sbt/io/PathMapper.scala
@@ -16,7 +16,7 @@ abstract class Mapper {
type PathMap = File => Option[String]
type FileMap = File => Option[File]
- /** A path mapper that pairs a File with the path returned by calling `getPath` on it.*/
+ /** A path mapper that pairs a File with the path returned by calling `getPath` on it. */
val basic: PathMap = f => Some(f.getPath)
/**
@@ -47,7 +47,7 @@ abstract class Mapper {
*/
def fail: Any => Nothing = f => sys.error("No mapping for " + f)
- /** A path mapper that pairs a File with its name. For example, `/x/y/z.txt` gets paired with `z.txt`.*/
+ /** A path mapper that pairs a File with its name. For example, `/x/y/z.txt` gets paired with `z.txt`. */
val flat: PathMap = f => Some(f.getName)
/**
@@ -59,10 +59,10 @@ abstract class Mapper {
(f => Some(newBase0 + f.getName))
}
- /** A mapper that is defined on all inputs by the function `f`.*/
+ /** A mapper that is defined on all inputs by the function `f`. */
def total[A, B](f: A => B): A => Some[B] = x => Some(f(x))
- /** A mapper that ignores all inputs.*/
+ /** A mapper that ignores all inputs. */
def transparent: Any => Option[Nothing] = _ => None
def normalizeBase(base: String) = if (!base.isEmpty && !base.endsWith("/")) base + "/" else base
@@ -134,7 +134,6 @@ abstract class Mapper {
* ...
* }}}
*
- *
* @param baseDirectory The directory that should be turned into a mappings sequence.
* @return mappings The `baseDirectory` and all of its contents
*/
diff --git a/io/src/main/scala/sbt/io/Using.scala b/io/src/main/scala/sbt/io/Using.scala
index b74b457b..2ffba15f 100644
--- a/io/src/main/scala/sbt/io/Using.scala
+++ b/io/src/main/scala/sbt/io/Using.scala
@@ -33,8 +33,8 @@ abstract class Using[Source, T] {
}
import scala.reflect.{ Manifest => SManifest }
-private[sbt] abstract class WrapUsing[Source, T](
- implicit srcMf: SManifest[Source],
+private[sbt] abstract class WrapUsing[Source, T](implicit
+ srcMf: SManifest[Source],
targetMf: SManifest[T]
) extends Using[Source, T] {
protected def label[S](m: SManifest[S]) = m.runtimeClass.getSimpleName
@@ -55,14 +55,14 @@ private[sbt] trait OpenFile[T] extends Using[File, T] {
}
object Using {
- def wrap[Source, T <: AutoCloseable](openF: Source => T)(
- implicit srcMf: SManifest[Source],
+ def wrap[Source, T <: AutoCloseable](openF: Source => T)(implicit
+ srcMf: SManifest[Source],
targetMf: SManifest[T]
): Using[Source, T] =
wrap(openF, closeCloseable)
- def wrap[Source, T](openF: Source => T, closeF: T => Unit)(
- implicit srcMf: SManifest[Source],
+ def wrap[Source, T](openF: Source => T, closeF: T => Unit)(implicit
+ srcMf: SManifest[Source],
targetMf: SManifest[T]
): Using[Source, T] =
new WrapUsing[Source, T] {
@@ -97,8 +97,8 @@ object Using {
val fileInputStream = file(f => new BufferedInputStream(new FileInputStream(f)))
- val urlInputStream = resource(
- (u: URL) => translate("Error opening " + u + ": ")(new BufferedInputStream(u.openStream))
+ val urlInputStream = resource((u: URL) =>
+ translate("Error opening " + u + ": ")(new BufferedInputStream(u.openStream))
)
val fileOutputChannel = file(f => new FileOutputStream(f).getChannel)
@@ -131,10 +131,9 @@ object Using {
val jarInputStream = wrap((in: InputStream) => new JarInputStream(in))
def zipEntry(zip: ZipFile) =
- resource(
- (entry: ZipEntry) =>
- translate("Error opening " + entry.getName + " in " + zip + ": ") {
- zip.getInputStream(entry)
- }
+ resource((entry: ZipEntry) =>
+ translate("Error opening " + entry.getName + " in " + zip + ": ") {
+ zip.getInputStream(entry)
+ }
)
}
diff --git a/io/src/main/scala/sbt/nio/file/FileAttributes.scala b/io/src/main/scala/sbt/nio/file/FileAttributes.scala
index 37e43dfc..c756da3b 100644
--- a/io/src/main/scala/sbt/nio/file/FileAttributes.scala
+++ b/io/src/main/scala/sbt/nio/file/FileAttributes.scala
@@ -69,9 +69,9 @@ object FileAttributes {
override def equals(o: Any): Boolean = o match {
case that: FileAttributesImpl =>
this.isDirectory == that.isDirectory &&
- this.isOther == that.isOther &&
- this.isRegularFile == that.isRegularFile &&
- this.isSymbolicLink == that.isSymbolicLink
+ this.isOther == that.isOther &&
+ this.isRegularFile == that.isRegularFile &&
+ this.isSymbolicLink == that.isSymbolicLink
case _ => false
}
override def toString: String =
diff --git a/io/src/main/scala/sbt/nio/file/FileTreeView.scala b/io/src/main/scala/sbt/nio/file/FileTreeView.scala
index 9d7a33f9..5b8c8c8e 100644
--- a/io/src/main/scala/sbt/nio/file/FileTreeView.scala
+++ b/io/src/main/scala/sbt/nio/file/FileTreeView.scala
@@ -247,14 +247,14 @@ object FileTreeView {
if ("nio" == System.getProperty("sbt.io.filetreeview", "")) nio else native
private[sbt] implicit class NioFileTreeViewOps[T](val view: FileTreeView.Nio[T]) {
def map[A >: T, B](f: (Path, A) => B): FileTreeView.Nio[B] = {
- val converter: ((Path, A)) => (Path, B) = {
- case (path: Path, attrs) => path -> f(path, attrs)
+ val converter: ((Path, A)) => (Path, B) = { case (path: Path, attrs) =>
+ path -> f(path, attrs)
}
(path: Path) => view.list(path).map(converter)
}
def flatMap[B, A >: T](f: (Path, A) => Traversable[B]): FileTreeView.Nio[B] = {
- val converter: ((Path, A)) => Traversable[(Path, B)] = {
- case (path: Path, attrs) => f(path, attrs).map(path -> _)
+ val converter: ((Path, A)) => Traversable[(Path, B)] = { case (path: Path, attrs) =>
+ f(path, attrs).map(path -> _)
}
(path: Path) => view.list(path).flatMap(converter(_))
}
@@ -297,20 +297,18 @@ object FileTreeView {
case _ => throw new IllegalStateException("Partition failed (should be unreachable).")
}
val rootPathsByParent = rootPaths.groupBy(_.getParent)
- val rootPathParams = rootPathsByParent.map {
- case (parent, paths) =>
- paths.map(_.getFileName) match {
- case Seq(fileName) => (parent, 1, Glob(parent, fileName.toString))
- case fileNames => (parent, 1, Glob(parent, fileNames.mkString("{", ",", "}")))
- }
+ val rootPathParams = rootPathsByParent.map { case (parent, paths) =>
+ paths.map(_.getFileName) match {
+ case Seq(fileName) => (parent, 1, Glob(parent, fileName.toString))
+ case fileNames => (parent, 1, Glob(parent, fileNames.mkString("{", ",", "}")))
+ }
}
val params = (rootPathParams.toSeq ++
rest.distinct.map(_.fileTreeViewListParameters)).sortBy(_._1)
var directoryCache: Option[(Path, ConcurrentHashMap[Path, FileAttributes])] = None
val needListDirectory: Path => Boolean = (path: Path) =>
- params.exists {
- case (base, maxDepth, _) =>
- path.startsWith(base) && base.relativize(path).getNameCount < maxDepth
+ params.exists { case (base, maxDepth, _) =>
+ path.startsWith(base) && base.relativize(path).getNameCount < maxDepth
}
val visited = new util.HashSet[Path]
val pathFilter: Path => Boolean = path => params.exists(_._3.matches(path))
@@ -341,7 +339,8 @@ object FileTreeView {
case Some((parent, m)) if parent == path.getParent => m
case _ =>
val map = new ConcurrentHashMap[Path, FileAttributes]()
- try view.list(path.getParent).foreach { case (p, a) => map.put(p, a) } catch {
+ try view.list(path.getParent).foreach { case (p, a) => map.put(p, a) }
+ catch {
case _: IOException =>
}
directoryCache = Some(path.getParent -> map)
diff --git a/io/src/main/scala/sbt/nio/file/Glob.scala b/io/src/main/scala/sbt/nio/file/Glob.scala
index 30eae7f3..f5a886e8 100644
--- a/io/src/main/scala/sbt/nio/file/Glob.scala
+++ b/io/src/main/scala/sbt/nio/file/Glob.scala
@@ -370,8 +370,8 @@ object Glob {
} else path
}
- private[sbt] def fileTreeViewListParameters(
- implicit option: RelativeGlobViewOption
+ private[sbt] def fileTreeViewListParameters(implicit
+ option: RelativeGlobViewOption
): (Path, Int, Glob) = {
val b = base
val r = range._2
@@ -503,7 +503,7 @@ object Glob {
path.iterator.asScala.toList match {
case Nil => Empty
case h :: Nil if h.getFileName.toString.isEmpty => Empty
- case parts => RelativeGlob(parts.map(p => PathComponent(p.getFileName.toString)))
+ case parts => RelativeGlob(parts.map(p => PathComponent(p.getFileName.toString)))
}
}
diff --git a/io/src/test/scala/sbt/internal/io/RetrySpec.scala b/io/src/test/scala/sbt/internal/io/RetrySpec.scala
index aa03aaea..00193497 100644
--- a/io/src/test/scala/sbt/internal/io/RetrySpec.scala
+++ b/io/src/test/scala/sbt/internal/io/RetrySpec.scala
@@ -33,10 +33,15 @@ final class RetrySpec extends AnyFlatSpec {
"retry" should "throw recover" in {
for (recoveryStep <- (1 to 14)) {
val i = new AtomicInteger()
- val value = Retry({
- val thisI = i.incrementAndGet()
- if (thisI == recoveryStep) "recover" else throw new IOException(thisI.toString)
- }, limit = 15, sleepInMillis = 0, noExcluded: _*)
+ val value = Retry(
+ {
+ val thisI = i.incrementAndGet()
+ if (thisI == recoveryStep) "recover" else throw new IOException(thisI.toString)
+ },
+ limit = 15,
+ sleepInMillis = 0,
+ noExcluded: _*
+ )
assert(value == "recover")
}
}
diff --git a/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala b/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala
index 0667ffb7..eeb98d0e 100644
--- a/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala
+++ b/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala
@@ -483,9 +483,10 @@ private[sbt] trait EventMonitorSpec { self: AnyFlatSpec with Matchers =>
final def writeNewFile(file: File, content: String, attempt: Int = 0): Unit = {
if (attempt == 0) IO.write(file, content)
// IO.setModifiedTimeOrFalse sometimes throws an invalid argument exception
- val res = try {
- IO.setModifiedTimeOrFalse(file, (Deadline.now - 5.seconds).time.toMillis)
- } catch { case _: IOException if attempt < 10 => false }
+ val res =
+ try {
+ IO.setModifiedTimeOrFalse(file, (Deadline.now - 5.seconds).time.toMillis)
+ } catch { case _: IOException if attempt < 10 => false }
if (!res) writeNewFile(file, content, attempt + 1)
}
@@ -503,8 +504,9 @@ object EventMonitorSpec {
}
@tailrec
final def realPath(path: Path, fileName: Option[Path] = None): Path = {
- val res: Path = try path.toRealPath()
- catch { case _: IOException => null }
+ val res: Path =
+ try path.toRealPath()
+ catch { case _: IOException => null }
if (res != null) fileName.fold(res)(res.resolve)
else {
val newFileName = path.getFileName
diff --git a/io/src/test/scala/sbt/internal/nio/MacOSXWatchServiceSpec.scala b/io/src/test/scala/sbt/internal/nio/MacOSXWatchServiceSpec.scala
index 7484cb89..9ffbf41a 100644
--- a/io/src/test/scala/sbt/internal/nio/MacOSXWatchServiceSpec.scala
+++ b/io/src/test/scala/sbt/internal/nio/MacOSXWatchServiceSpec.scala
@@ -58,6 +58,7 @@ class MacOSXWatchServiceSpec extends AnyFlatSpec {
})
} finally service.close()
()
- } else {}
+ }
+ else {}
"MacOSXWatchService" should "handle overlapping directories" in test()
}
diff --git a/io/src/test/scala/sbt/internal/nio/PathSyntaxSpec.scala b/io/src/test/scala/sbt/internal/nio/PathSyntaxSpec.scala
index 2ab3b53b..7f33e3e9 100644
--- a/io/src/test/scala/sbt/internal/nio/PathSyntaxSpec.scala
+++ b/io/src/test/scala/sbt/internal/nio/PathSyntaxSpec.scala
@@ -45,7 +45,7 @@ class PathSyntaxSpec extends AnyFlatSpec {
it should "work with empty paths" in {
val empty = Paths.get("").toGlob match {
case r: RelativeGlob => r
- case _ => throw new IllegalStateException("Relative path was not converted to relative glob")
+ case _ => throw new IllegalStateException("Relative path was not converted to relative glob")
}
val glob = basePath.toGlob / empty / ** / empty / empty / "*.txt"
assert(glob.matches(basePath / "foo.txt"))
diff --git a/io/src/test/scala/sbt/io/CopySpec.scala b/io/src/test/scala/sbt/io/CopySpec.scala
index 8b442998..aa56740a 100644
--- a/io/src/test/scala/sbt/io/CopySpec.scala
+++ b/io/src/test/scala/sbt/io/CopySpec.scala
@@ -32,16 +32,15 @@ object CopySpec extends Properties("Copy") {
1 -> Gen.const(0)
)
- property("same contents") = forAll(fileSizeGen, arbLong.arbitrary)(
- (size: Long, seed: Long) =>
- IO.withTemporaryDirectory { dir =>
- val f1 = new File(dir, "source")
- val f2 = new File(dir, "dest")
- generate(seed = seed, size = size, file = f1)
- IO.copyFile(f1, f2)
- checkContentsSame(f1, f2)
- true
- }
+ property("same contents") = forAll(fileSizeGen, arbLong.arbitrary)((size: Long, seed: Long) =>
+ IO.withTemporaryDirectory { dir =>
+ val f1 = new File(dir, "source")
+ val f2 = new File(dir, "dest")
+ generate(seed = seed, size = size, file = f1)
+ IO.copyFile(f1, f2)
+ checkContentsSame(f1, f2)
+ true
+ }
)
def generate(seed: Long, size: Long, file: File) = {
diff --git a/io/src/test/scala/sbt/io/LastModifiedSpec.scala b/io/src/test/scala/sbt/io/LastModifiedSpec.scala
index b24b68a2..77c4a3a2 100644
--- a/io/src/test/scala/sbt/io/LastModifiedSpec.scala
+++ b/io/src/test/scala/sbt/io/LastModifiedSpec.scala
@@ -20,8 +20,8 @@ class LastModifiedSpec extends AnyFlatSpec {
dir =>
val fileName = "a" * 32
val nested =
- (1 to 8).foldLeft(dir.toPath) {
- case (d, _) => Files.createDirectories(d.resolve(fileName))
+ (1 to 8).foldLeft(dir.toPath) { case (d, _) =>
+ Files.createDirectories(d.resolve(fileName))
}
val file = Files.createFile(nested.resolve(fileName)).toFile
// in case target platform only has second precision round to nearest second
diff --git a/io/src/test/scala/sbt/io/NameFilterSpecification.scala b/io/src/test/scala/sbt/io/NameFilterSpecification.scala
index 5273db41..36a01127 100644
--- a/io/src/test/scala/sbt/io/NameFilterSpecification.scala
+++ b/io/src/test/scala/sbt/io/NameFilterSpecification.scala
@@ -15,13 +15,11 @@ import org.scalacheck._, Prop._
object NameFilterSpecification extends Properties("NameFilter") {
property("All pass accepts everything") = forAll((s: String) => AllPassFilter.accept(s))
- property("Exact filter matches provided string") = forAll(
- (s1: String, s2: String) => (new ExactFilter(s1)).accept(s2) == (s1 == s2)
- )
+ property("Exact filter matches provided string") =
+ forAll((s1: String, s2: String) => (new ExactFilter(s1)).accept(s2) == (s1 == s2))
- property("Exact filter matches valid string") = forAll(
- (s: String) => (new ExactFilter(s)).accept(s)
- )
+ property("Exact filter matches valid string") =
+ forAll((s: String) => (new ExactFilter(s)).accept(s))
property("Glob filter matches provided string if no *s") = forAll { (s1: String, s2: String) =>
val stripped = stripAsterisksAndControl(s1)
diff --git a/io/src/test/scala/sbt/io/PathMapperSpec.scala b/io/src/test/scala/sbt/io/PathMapperSpec.scala
index 51617159..5b22638c 100644
--- a/io/src/test/scala/sbt/io/PathMapperSpec.scala
+++ b/io/src/test/scala/sbt/io/PathMapperSpec.scala
@@ -32,8 +32,8 @@ class PathMapperSpec extends flatspec.FixtureAnyFlatSpec with Matchers {
)
val target = base / "target" / "scala-2.11" / "classes"
- val mappings = (files --- dirs) pair (
- file => rebase(dirs, target)(file) orElse (flat(target): File => Option[File])(file)
+ val mappings = (files --- dirs) pair (file =>
+ rebase(dirs, target)(file) orElse (flat(target): File => Option[File])(file)
)
mappings shouldBe Seq(
diff --git a/io/src/test/scala/sbt/nio/PathFilterSpec.scala b/io/src/test/scala/sbt/nio/PathFilterSpec.scala
index f8865727..7dee3836 100644
--- a/io/src/test/scala/sbt/nio/PathFilterSpec.scala
+++ b/io/src/test/scala/sbt/nio/PathFilterSpec.scala
@@ -102,8 +102,8 @@ class PathFilterSpec extends AnyFlatSpec {
assert(notHiddenFileFilter.accept(regular))
assert((!notHiddenFileFilter).accept(hidden))
- val directoryFilterAndHidden
- : PathFilter = sbt.io.DirectoryFilter.toNio && sbt.io.HiddenFileFilter
+ val directoryFilterAndHidden: PathFilter =
+ sbt.io.DirectoryFilter.toNio && sbt.io.HiddenFileFilter
val hiddenDir = Files.createDirectories(dirPath / ".hidden").setHidden()
assert(directoryFilterAndHidden.accept(hiddenDir) == !isWin)
assert(!directoryFilterAndHidden.accept(dirPath))
diff --git a/project/HouseRulesPluglin.scala b/project/HouseRulesPluglin.scala
index d9f758b1..71fce48c 100644
--- a/project/HouseRulesPluglin.scala
+++ b/project/HouseRulesPluglin.scala
@@ -29,8 +29,8 @@ object HouseRulesPlugin extends AutoPlugin {
scalacOptions ++= "-Ywarn-dead-code".ifScala213OrMinus.value.toList,
scalacOptions ++= "-Ywarn-numeric-widen".ifScala213OrMinus.value.toList,
scalacOptions ++= "-Ywarn-value-discard".ifScala213OrMinus.value.toList,
- ) ++ Seq(Compile, Test).flatMap(
- c => (c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
+ ) ++ Seq(Compile, Test).flatMap(c =>
+ (c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
)
private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)