Skip to content

Commit

Permalink
Update scalafmt-core to 3.8.5 (#270)
Browse files Browse the repository at this point in the history
Co-authored-by: scala-steward <scala-steward>
  • Loading branch information
softwaremill-ci authored Jan 21, 2025
1 parent d39b305 commit 4534479
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ b73b3c3f8fcaaa70595cd267f7242b0a0c345039

# Scala Steward: Reformat with scalafmt 3.8.3
9cc844f181b6f41a327bbff0c18a8c6621532ef1

# Scala Steward: Reformat with scalafmt 3.8.5
49688a6ac2f4d2b05006524970e3758aa84002c0
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.3
version = 3.8.5
maxColumn = 140
runner.dialect = scala3

Expand Down
6 changes: 6 additions & 0 deletions core/src/main/scala/ox/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ object either:
error("The enclosing `either` call uses a different error type.\nIf it's explicitly typed, is the error type correct?")
case _ => error("`.ok()` can only be used within an `either` call.\nIs it present?")
}
end extension

/** Specialized extensions for Right & Left are necessary to prevent compile-time warning about unreachable cases in inlined pattern
* matches when call site has a specific type.
Expand All @@ -77,6 +78,7 @@ object either:
error("The enclosing `either` call uses a different error type.\nIf it's explicitly typed, is the error type correct?")
case _ => error("`.ok()` can only be used within an `either` call.\nIs it present?")
}
end extension

extension [A](inline t: Option[A])
/** Unwrap the value of the `Option`, short-circuiting the computation to the enclosing [[either]], in case this is a `None`. */
Expand All @@ -92,6 +94,7 @@ object either:
)
case _ => error("`.ok()` can only be used within an `either` call.\nIs it present?")
}
end extension

/** Specialized extensions for Some & None are necessary to prevent compile-time warning about unreachable cases in inlined pattern
* matches when call site has a specific type.
Expand All @@ -111,6 +114,7 @@ object either:
)
case _ => error("`.ok()` can only be used within an `either` call.\nIs it present?")
}
end extension

extension [E, A](inline f: Fork[Either[E, A]])
/** Join the fork and unwrap the value of its `Either` result, short-circuiting the computation to the enclosing [[either]], in case
Expand All @@ -120,6 +124,7 @@ object either:
* this method only when the fork is started using [[forkUnsupervised]] or [[forkCancellable]].
*/
transparent inline def ok(): A = f.join().ok()
end extension

extension [E](e: E)
/** Fail the computation, short-circuiting to the enclosing [[either]] block. */
Expand All @@ -129,6 +134,7 @@ object either:
case given boundary.Label[Either[Nothing, Nothing]] =>
error("The enclosing `either` call uses a different error type.\nIf it's explicitly typed, is the error type correct?")
}
end extension

extension [E <: Throwable, T](e: Either[E, T])
/** Unwrap the right-value of the `Either`, throwing the contained exception if this is a lef-value. For a variant which allows
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/scala/ox/flow/FlowCompanionReactiveOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ trait FlowCompanionReactiveOps:

def onNext(t: T): Unit = channel.send(t)
def onError(t: Throwable): Unit = channel.error(t)
def onComplete(): Unit = channel.done()
)
def onComplete(): Unit = channel.done())
}.discard

repeatWhile:
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/ox/flow/FlowIOOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ trait FlowIOOps[+T]:
case chunk: T @unchecked =>
currentChunk = chunk.iterator
currentChunk.next() & 0xff // Convert to unsigned
end read

override def available: Int =
currentChunk.length
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/scala/ox/flow/FlowOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class FlowOps[+T]:
if taken == n then throw abortTake
)
catch case `abortTake` => () // done
end try

/** Transform the flow so that it emits elements as long as predicate `f` is satisfied (returns `true`). If `includeFirstFailing` is
* `true`, the flow will additionally emit the first element that failed the predicate. After that, the flow will complete as done.
Expand Down Expand Up @@ -764,8 +765,8 @@ class FlowOps[+T]:
// in special case when step == 1, we have to send the buffer immediately
if buffer.size == n then emit(buffer)
else
// step > n - we drop `step` elements and continue appending until buffer size is n
if buffer.size == step then buffer = buffer.drop(step)
// step > n - we drop `step` elements and continue appending until buffer size is n
if buffer.size == step then buffer = buffer.drop(step)
end if
)
// send the remaining elements, only if these elements were not yet sent
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/scala/ox/flow/FlowRunOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ trait FlowRunOps[+T]:
last.run(FlowEmit.fromInline: t =>
current match
case None => current = Some(t)
case Some(c) => current = Some(f(c, t))
)
case Some(c) => current = Some(f(c, t)))

current.getOrElse(throw new NoSuchElementException("cannot reduce an empty flow"))
end runReduce
Expand Down
3 changes: 1 addition & 2 deletions core/src/test/scala/ox/ExceptionTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ class ExceptionTest extends AnyFlatSpec with Matchers:
}
f.join()
}
catch
case e: Exception => addExceptionWithSuppressedTo(trail, e)
catch case e: Exception => addExceptionWithSuppressedTo(trail, e)

// either join() might throw the original exception (shouldn't be suppressed), or it might be interrupted before
// throwing (should be suppressed then)
Expand Down
13 changes: 5 additions & 8 deletions core/src/test/scala/ox/OxAppTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class OxAppTest extends AnyFlatSpec with Matchers:
val sw = StringWriter()
val pw = PrintWriter(sw)
t.printStackTrace(pw)
stackTrace = sw.toString
)
stackTrace = sw.toString)
end Main31

Main31.main(Array.empty)
Expand All @@ -114,8 +113,7 @@ class OxAppTest extends AnyFlatSpec with Matchers:
val sw = StringWriter()
val pw = PrintWriter(sw)
t.printStackTrace(pw)
stackTrace = sw.toString
)
stackTrace = sw.toString)
end Main32

Main32.main(Array.empty)
Expand Down Expand Up @@ -224,8 +222,7 @@ class OxAppTest extends AnyFlatSpec with Matchers:
val sw = StringWriter()
val pw = PrintWriter(sw)
t.printStackTrace(pw)
stackTrace = sw.toString
)
stackTrace = sw.toString)
end Main70

Main70.main(Array.empty)
Expand Down Expand Up @@ -325,10 +322,10 @@ class OxAppTest extends AnyFlatSpec with Matchers:
val sw = StringWriter()
val pw = PrintWriter(sw)
t.printStackTrace(pw)
stackTrace = sw.toString
)
stackTrace = sw.toString)

override def handleError(e: FunException): ExitCode = ??? // should not get called!
end Main101

Main101.main(Array.empty)

Expand Down
3 changes: 1 addition & 2 deletions core/src/test/scala/ox/ParTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class ParTest extends AnyFlatSpec with Matchers:
throw new Exception("boom")
}
)
catch
case e: Exception if e.getMessage == "boom" => trail.add("catch")
catch case e: Exception if e.getMessage == "boom" => trail.add("catch")

// checking if the forks aren't left running
end try
Expand Down
1 change: 1 addition & 0 deletions core/src/test/scala/ox/RaceTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class RaceTest extends AnyFlatSpec with Matchers:
catch
case e: StackOverflowError => // the expected exception
flag.get() shouldBe false // because a fatal exception was thrown, the second computation should be interrupted
end try
}

"raceEither" should "return the first successful computation to complete" in {
Expand Down
3 changes: 2 additions & 1 deletion core/src/test/scala/ox/flow/FlowIOOpsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class FlowIOOpsTest extends AnyWordSpec with Matchers:
}
val sourceContent = "source.toFile test3 content"
filePath = folderPath.resolve("test-writefile3")
Flow.fromIterable(sourceContent.grouped(4).toList.map(chunkStr => Chunk.fromArray(chunkStr.getBytes)))
Flow
.fromIterable(sourceContent.grouped(4).toList.map(chunkStr => Chunk.fromArray(chunkStr.getBytes)))
.runToFile(filePath)

fileContent(filePath) shouldBe List(sourceContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extension [A](flow: Flow[A])
*/
def toReactiveStreamsPublisher(using Ox, BufferCapacity): Publisher[A] =
FlowAdapters.toPublisher(flow.toPublisher)
end extension

object FlowReactiveStreams:
/** This variant returns accepts an implementation of `org.reactivestreams.Publisher`, as opposed to `java.util.concurrent.Flow.Publisher`
Expand Down

0 comments on commit 4534479

Please sign in to comment.