Skip to content

Commit

Permalink
reducing line length to <= 100 chars - I miss scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mpollmeier committed Feb 17, 2023
1 parent 2792d8b commit ab3e5ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
13 changes: 9 additions & 4 deletions os/src/Using.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ import scala.util.control.{ControlThrowable, NonFatal}
* - `java.lang.VirtualMachineError`
* - `java.lang.LinkageError`
* - `java.lang.InterruptedException` and `java.lang.ThreadDeath`
* - [[scala.util.control.NonFatal fatal exceptions]], excluding `scala.util.control.ControlThrowable`
* - [[scala.util.control.NonFatal fatal exceptions]], excluding
* `scala.util.control.ControlThrowable`
* - `scala.util.control.ControlThrowable`
* - all other exceptions
*
Expand All @@ -115,7 +116,8 @@ object Using {
* @return a [[Try]] containing an exception if one or more were thrown,
* or the result of the operation if no exceptions were thrown
*/
def apply[R: Releasable, A](resource: => R)(f: R => A): Try[A] = Try { Using.resource(resource)(f) }
def apply[R: Releasable, A](resource: => R)(f: R => A): Try[A] =
Try { Using.resource(resource)(f) }

/** A resource manager.
*
Expand Down Expand Up @@ -236,10 +238,13 @@ object Using {
case _: LinkageError => 3
case _: InterruptedException | _: ThreadDeath => 2
case _: ControlThrowable => 0
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
case e if !NonFatal(e) =>
1 // in case this method gets out of sync with NonFatal
case _ => -1
}
@inline def suppress(t: Throwable, suppressed: Throwable): Throwable = { t.addSuppressed(suppressed); t }
@inline def suppress(t: Throwable, suppressed: Throwable): Throwable = {
t.addSuppressed(suppressed); t
}

if (score(secondary) > score(primary)) suppress(secondary, primary)
else suppress(primary, secondary)
Expand Down
15 changes: 10 additions & 5 deletions os/test/src/TempPathTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ object TempPathTests extends TestSuite{
tempFilePath = file.toString
assert(os.exists(file))
}
assert(!os.exists(os.Path(tempFilePath)), s"temp file did not get auto-deleted after `Using` block: $tempFilePath")
assert(!os.exists(os.Path(tempFilePath)),
s"temp file did not get auto-deleted after `Using` block: $tempFilePath")
}
test("temp.withDir") {
var tempDirPath: String = null
Expand All @@ -28,7 +29,8 @@ object TempPathTests extends TestSuite{
assert(os.exists(dir))
assert(os.exists(file))
}
assert(!os.exists(os.Path(tempDirPath)), s"temp dir did not get auto-deleted after `Using` block: $tempDirPath")
assert(!os.exists(os.Path(tempDirPath)),
s"temp dir did not get auto-deleted after `Using` block: $tempDirPath")
}
}

Expand All @@ -39,7 +41,8 @@ object TempPathTests extends TestSuite{
tempFilePath = file.toString
assert(os.exists(file))
}
assert(!os.exists(os.Path(tempFilePath)), s"temp file did not get auto-deleted after `Using` block: $tempFilePath")
assert(!os.exists(os.Path(tempFilePath)),
s"temp file did not get auto-deleted after `Using` block: $tempFilePath")
}
test("directory") {
var tempDirPath: String = null
Expand All @@ -52,7 +55,8 @@ object TempPathTests extends TestSuite{
assert(os.exists(dir))
assert(os.exists(file))
}
assert(!os.exists(os.Path(tempDirPath)), s"temp dir did not get auto-deleted after `Using` block: $tempDirPath")
assert(!os.exists(os.Path(tempDirPath)),
s"temp dir did not get auto-deleted after `Using` block: $tempDirPath")
}

test("multiple files") {
Expand All @@ -65,7 +69,8 @@ object TempPathTests extends TestSuite{
files.foreach(file => assert(os.exists(file)))
}
tempFilePaths.foreach { file =>
assert(!os.exists(os.Path(file)), s"temp file did not get auto-deleted after `Using` block: $file")
assert(!os.exists(os.Path(file)),
s"temp file did not get auto-deleted after `Using` block: $file")
}
}
}
Expand Down

0 comments on commit ab3e5ad

Please sign in to comment.