From a02fbaba1fc41c0a915242312270fb91a5ede982 Mon Sep 17 00:00:00 2001 From: counter2015 Date: Thu, 14 Nov 2024 14:00:56 +0800 Subject: [PATCH] Fix some warning and doc syntax typo. --- build.mill | 2 ++ os/src/GlobInterpolator.scala | 4 ++-- os/src/ListOps.scala | 22 +++++++++++----------- os/src/SubProcess.scala | 18 ++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build.mill b/build.mill index bcd232ce..bfdcdb33 100644 --- a/build.mill +++ b/build.mill @@ -43,6 +43,8 @@ trait AcyclicModule extends ScalaModule { def scalacOptions = super.scalacOptions() ++ acyclicOptions() ++ Seq( "-deprecation", "-feature", + "-language:implicitConversions", + "-language:higherKinds", ) } diff --git a/os/src/GlobInterpolator.scala b/os/src/GlobInterpolator.scala index 73a11c0a..4c7f3edb 100644 --- a/os/src/GlobInterpolator.scala +++ b/os/src/GlobInterpolator.scala @@ -2,8 +2,8 @@ package os object GlobInterpolator { class Interped(parts: Seq[String]) { - def unapplySeq(s: String) = { - val Seq(head, tail @ _*) = parts.map(java.util.regex.Pattern.quote) + def unapplySeq(s: String): Option[List[String]] = { + val Seq(head, tail @ _*) = parts.map(java.util.regex.Pattern.quote): @unchecked val regex = head + tail.map("(.*)" + _).mkString regex.r.unapplySeq(s) diff --git a/os/src/ListOps.scala b/os/src/ListOps.scala index 05257407..5306b13e 100644 --- a/os/src/ListOps.scala +++ b/os/src/ListOps.scala @@ -17,7 +17,7 @@ import java.nio.file.attribute.BasicFileAttributes object list extends Function1[Path, IndexedSeq[Path]] { def apply(src: Path, sort: Boolean = true): IndexedSeq[Path] = { val arr = stream(src).toArray[Path] - if (sort) arr.sorted + if (sort) arr.sorted.toIndexedSeq else arr } def apply(src: Path): IndexedSeq[Path] = apply(src, true).toIndexedSeq @@ -53,7 +53,7 @@ object list extends Function1[Path, IndexedSeq[Path]] { * saving time as compared to filtering them after the fact. * * By default, the paths are returned as a pre-order traversal: the enclosing - * folder is occurs first before any of it's contents. You can pass in `preOrder = + * folder occurs first before any of its contents. You can pass in `preOrder = * false` to turn it into a post-order traversal, such that the enclosing folder * occurs last after all it's contents. * @@ -76,12 +76,12 @@ object walk { * you want `preOrder` to be `true` so the folder gets * created first. * - * @param followLinks Whether or not to follow symlinks while walking; defaults + * @param followLinks Whether to follow symlinks while walking; defaults * to false * * @param maxDepth The max depth of the tree you wish to walk; defaults to unlimited * - * @param includeTarget Whether or not to include the given path as part of the walk. + * @param includeTarget Whether to include the given path as part of the walk. * If `true`, does not raise an error if the given path is a * simple file and not a folder */ @@ -109,12 +109,12 @@ object walk { * you want `preOrder` to be `true` so the folder gets * created first. * - * @param followLinks Whether or not to follow symlinks while walking; defaults + * @param followLinks Whether to follow symlinks while walking; defaults * to false * * @param maxDepth The max depth of the tree you wish to walk; defaults to unlimited * - * @param includeTarget Whether or not to include the given path as part of the walk. + * @param includeTarget Whether to include the given path as part of the walk. * If `true`, does not raise an error if the given path is a * simple file and not a folder */ @@ -145,12 +145,12 @@ object walk { * you want `preOrder` to be `true` so the folder gets * created first. * - * @param followLinks Whether or not to follow symlinks while walking; defaults + * @param followLinks Whether to follow symlinks while walking; defaults * to false * * @param maxDepth The max depth of the tree you wish to walk; defaults to unlimited * - * @param includeTarget Whether or not to include the given path as part of the walk. + * @param includeTarget Whether to include the given path as part of the walk. * If `true`, does not raise an error if the given path is a * simple file and not a folder */ @@ -179,12 +179,12 @@ object walk { * you want `preOrder` to be `true` so the folder gets * created first. * - * @param followLinks Whether or not to follow symlinks while walking; defaults + * @param followLinks Whether to follow symlinks while walking; defaults * to false * * @param maxDepth The max depth of the tree you wish to walk; defaults to unlimited * - * @param includeTarget Whether or not to include the given path as part of the walk. + * @param includeTarget Whether to include the given path as part of the walk. * If `true`, does not raise an error if the given path is a * simple file and not a folder */ @@ -228,7 +228,7 @@ object walk { // rather than relying on `walkFileTree`, because `walkFileTree` // does the unintuitive thing when the `path` being walked is a // symlink to a directory (it just returns the symlink path and - // does not walking) + // does not walk) val ds = Files.newDirectoryStream(pathNIO) val iter = ds.iterator() try { diff --git a/os/src/SubProcess.scala b/os/src/SubProcess.scala index 9f624819..680e077f 100644 --- a/os/src/SubProcess.scala +++ b/os/src/SubProcess.scala @@ -51,7 +51,7 @@ sealed trait ProcessLike extends java.lang.AutoCloseable { /** * Wait up to `millis` for the [[ProcessLike]] to terminate and all stdout and stderr - * from the subprocess to be handled. By default waits indefinitely; if a time + * from the subprocess to be handled. By default, waits indefinitely; if a time * limit is given, explicitly destroys the [[ProcessLike]] if it has not completed by * the time the timeout has occurred. * @@ -152,7 +152,7 @@ class SubProcess( * @param async set this to `true` if you do not want to wait on the subprocess exiting * @param shutdownGracePeriod use this to override the default wait time for the subprocess * to gracefully exit before destroying it forcibly. Defaults to the `shutdownGracePeriod` - * that was used to spawned the process, but can be set to 0 + * that was used to spawn the process, but can be set to 0 * (i.e. force exit immediately) or -1 (i.e. never force exit) * or anything in between. Typically defaults to 100 milliseconds. */ @@ -183,7 +183,7 @@ class SubProcess( /** * Alias for [[destroy]] */ - def close() = wrapped.destroy() + def close(): Unit = wrapped.destroy() /** * Wait up to `millis` for the subprocess to terminate, by default waits @@ -296,7 +296,7 @@ object SubProcess { out.toByteArray } - override def close() = wrapped.close() + override def close(): Unit = wrapped.close() } } @@ -314,7 +314,7 @@ class ProcessPipeline( /** * String representation of the pipeline. */ - def commandString = processes.map(_.wrapped.toString).mkString(" | ") + def commandString: String = processes.map(_.wrapped.toString).mkString(" | ") private[os] val brokenPipeHandler: Option[Thread] = brokenPipeQueue.map { queue => new Thread( @@ -326,7 +326,7 @@ class ProcessPipeline( if (brokenPipeIndex == processes.length) { // Special case signaling finished pipeline pipelineRunning = false } else { - processes(brokenPipeIndex).destroyForcibly() + processes(brokenPipeIndex).destroy(shutdownGracePeriod = 0) } } new Thread( @@ -354,9 +354,7 @@ class ProcessPipeline( */ override def exitCode(): Int = { if (pipefail) - processes.map(_.exitCode()) - .filter(_ != 0) - .headOption + processes.map(_.exitCode()).find(_ != 0) .getOrElse(0) else processes.last.exitCode() @@ -383,7 +381,7 @@ class ProcessPipeline( * All processes in the pipeline are force-destroyed. */ override def destroyForcibly(): Unit = { - processes.foreach(_.destroyForcibly()) + processes.foreach(_.destroy(shutdownGracePeriod = 0)) } /**