Skip to content

Commit

Permalink
Fix some warning and doc syntax typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
counter2015 committed Nov 14, 2024
1 parent 209e814 commit a02fbab
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 2 additions & 0 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ trait AcyclicModule extends ScalaModule {
def scalacOptions = super.scalacOptions() ++ acyclicOptions() ++ Seq(
"-deprecation",
"-feature",
"-language:implicitConversions",
"-language:higherKinds",
)
}

Expand Down
4 changes: 2 additions & 2 deletions os/src/GlobInterpolator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions os/src/ListOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 8 additions & 10 deletions os/src/SubProcess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -296,7 +296,7 @@ object SubProcess {
out.toByteArray
}

override def close() = wrapped.close()
override def close(): Unit = wrapped.close()
}
}

Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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()
Expand All @@ -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))
}

/**
Expand Down

0 comments on commit a02fbab

Please sign in to comment.