Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scalafmt-core to 2.7.5 #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2.4.2"
version = "2.7.5"
maxColumn = 120
align = most
continuationIndent.defnSite = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class DeadLettersMonitorRouteSpec
val json = parse(responseAs[String]).getOrElse(fail("Invalid json"))

val unhandled = json.hcursor.downField("snapshot").downField("unhandled")
unhandled.downArray.downField("value").downField("message").as[String] shouldBe Right("UnknownMessage(\"this\\\"is a \"\\\" tough message)")
unhandled.downArray.downField("value").downField("message").as[String] shouldBe Right(
"UnknownMessage(\"this\\\"is a \"\\\" tough message)"
)
}
)
}
Expand Down
14 changes: 7 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ val core = (project in file("core"))
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"io.circe" %% "circe-parser" % circeVersion % Test,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test
"io.circe" %% "circe-parser" % circeVersion % Test,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test
)
)
.settings(publishSettings: _*)
Expand All @@ -110,16 +110,16 @@ val akkaHttp = (project in file("akka-http"))
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"io.circe" %% "circe-parser" % circeVersion % Test,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test
"io.circe" %% "circe-parser" % circeVersion % Test,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test
)
)
.settings(publishSettings: _*)
.dependsOn(core % "compile->compile;test->test")

val root = (project in file("."))
val root = (project in file("."))
.settings(buildSettings: _*)
.settings(publishSettings: _*)
.settings(noPublishSettings: _*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import io.scalac.periscope.common.{ ArrayDeque, Deque }

private[deadletters] class DeadLettersDataCollector(keepMax: Int) extends AbstractDeadLettersDataCollector(keepMax) {

override protected val lastDeadLetters: Deque[Timestamped[DeadLetter]] = ArrayDeque(
override protected val lastDeadLetters: Deque[Timestamped[DeadLetter]] = ArrayDeque(
new scala.collection.mutable.ArrayBuffer(keepMax)
)
override protected val lastUnhandled: Deque[Timestamped[UnhandledMessage]] = ArrayDeque(
new scala.collection.mutable.ArrayBuffer(keepMax)
)
override protected val lastDropped: Deque[Timestamped[Dropped]] = ArrayDeque(
override protected val lastDropped: Deque[Timestamped[Dropped]] = ArrayDeque(
new scala.collection.mutable.ArrayBuffer(keepMax)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import io.scalac.periscope.common.{ ArrayDeque, Deque }

private[deadletters] class DeadLettersDataCollector(keepMax: Int) extends AbstractDeadLettersDataCollector(keepMax) {

override protected val lastDeadLetters: Deque[Timestamped[DeadLetter]] = ArrayDeque(
override protected val lastDeadLetters: Deque[Timestamped[DeadLetter]] = ArrayDeque(
new scala.collection.mutable.ArrayDeque(keepMax)
)
override protected val lastUnhandled: Deque[Timestamped[UnhandledMessage]] = ArrayDeque(
new scala.collection.mutable.ArrayDeque(keepMax)
)
override protected val lastDropped: Deque[Timestamped[Dropped]] = ArrayDeque(
override protected val lastDropped: Deque[Timestamped[Dropped]] = ArrayDeque(
new scala.collection.mutable.ArrayDeque(keepMax)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ package object counter {

def count(system: ActorSystem)(implicit ec: ExecutionContext, timeout: Timeout): Future[Long] = {
val correlation = Instant.now().toEpochMilli
val counter = system.actorOf(
val counter = system.actorOf(
Props(new ActorCounter(correlation)),
s"actor-counter-$correlation"
)
counter ! Count
val result = after(timeout.duration, system.scheduler)((counter ? GetResult).mapTo[Long])
val result = after(timeout.duration, system.scheduler)((counter ? GetResult).mapTo[Long])
result.onComplete(_ => system.stop(counter))
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ trait DeadLettersMonitor {
}

object DeadLettersMonitor {
def start(keepMax: Int, name: String = "DeadLettersMonitor")(
implicit system: ActorSystem,
def start(keepMax: Int, name: String = "DeadLettersMonitor")(implicit
system: ActorSystem,
timeout: Timeout
): DeadLettersMonitor = {
val collector = system.actorOf(Props(new DeadLettersDataCollector(keepMax)), name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ object Snapshot {
private def vectorToJson[A](v: Vector[Timestamped[A]], atoj: A => String) =
if (v.isEmpty) "[]"
else
v.foldLeft("[") {
case (agg, i) =>
s"""$agg{"timestamp":${i.timestamp},"value":${atoj(i.value)}},"""
}
.init + "]"
v.foldLeft("[") { case (agg, i) =>
s"""$agg{"timestamp":${i.timestamp},"value":${atoj(i.value)}},"""
}.init + "]"

private def deadLetterToJson(a: DeadLetter) =
s"""{"message":"${json.escape(a.message.toString)}","sender":"${a.sender.toString()}","recipient":"${a.recipient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ final case class WindowSnapshot(
deadLetters: WindowData,
unhandled: WindowData,
dropped: WindowData
){
def toJson = s"""{"withinMillis":$withinMillis,"deadLetters":${deadLetters.toJson},"unhandled":${unhandled.toJson},"dropped":${dropped.toJson}}"""
) {
def toJson =
s"""{"withinMillis":$withinMillis,"deadLetters":${deadLetters.toJson},"unhandled":${unhandled.toJson},"dropped":${dropped.toJson}}"""
}

final case class WindowData(count: Int, isMinimumEstimate: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ final case class ActorTree(nodes: Map[String, ActorTree]) extends AnyVal {
if (nodes.isEmpty) "{}"
else
nodes
.foldLeft("{") {
case (agg, (actor, children)) =>
s"""$agg"$actor":${children.asJson},"""
.foldLeft("{") { case (agg, (actor, children)) =>
s"""$agg"$actor":${children.asJson},"""
}
.init + "}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import scala.collection.mutable

private[tree] final class MutableActorTree(val nodes: mutable.Map[String, MutableActorTree]) extends AnyVal {
def insert(p: ActorPath): MutableActorTree =
p.elements.foldLeft(this) {
case (n, segment) =>
n.nodes.getOrElseUpdate(segment, new MutableActorTree(mutable.Map.empty))
p.elements.foldLeft(this) { case (n, segment) =>
n.nodes.getOrElseUpdate(segment, new MutableActorTree(mutable.Map.empty))
}

def toActorTree: ActorTree = ActorTree(nodes.map { case (k, v) => k -> v.toActorTree }.toMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ package object tree {

def build(system: ActorSystem)(implicit ec: ExecutionContext, timeout: Timeout): Future[ActorTree] = {
val correlation = Instant.now().toEpochMilli
val builder = system.actorOf(
val builder = system.actorOf(
Props(new ActorTreeBuilder(correlation)),
s"actor-tree-builder-$correlation"
)
builder ! Build
val result = after(timeout.duration, system.scheduler)((builder ? GetTree).mapTo[ActorTree])
val result = after(timeout.duration, system.scheduler)((builder ? GetTree).mapTo[ActorTree])
result.onComplete(_ => system.stop(builder))
result
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/io/scalac/periscope/common/Deque.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.scalac.periscope.common

/**
Cross-compilation helper, abstracting over a specific queue implementation.
Allows to use a more performant ArrayDeque in Scala 2.13.
* Cross-compilation helper, abstracting over a specific queue implementation.
* Allows to use a more performant ArrayDeque in Scala 2.13.
*/
trait Deque[A] {
def toVector: Vector[A]
Expand Down
8 changes: 4 additions & 4 deletions core/src/test/scala/io/scalac/periscope/akka/actors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.scalac.periscope.akka
import akka.actor.{ Actor, Props }

class ActorA extends Actor {
def receive: Receive = {
case _: KnownMessage => ()
def receive: Receive = { case _: KnownMessage =>
()
}
override def preStart(): Unit = {
context.actorOf(Props(new ActorB), name = "ab")
Expand Down Expand Up @@ -38,8 +38,8 @@ class OverwhelmedActorParent extends Actor {
}

class OverwhelmedActor extends Actor {
def receive: Receive = {
case () => Thread.sleep(5000)
def receive: Receive = { case () =>
Thread.sleep(5000)
}
override def preStart(): Unit =
self.!(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ class DeadLettersDataCollectorSpec
eventually {
val window = (collector ? CalculateForWindow(withinTime.toMillis * 2)).mapTo[WindowSnapshot].futureValue
val snapshot = (collector ? GetSnapshot).mapTo[Snapshot].futureValue
inside(snapshot.unhandled) {
case Vector(m1, m2, m3) =>
// reverse order - latest first
m1.value.message shouldBe UnknownMessage("Luke, I'm your father!")
m2.value.message shouldBe UnknownMessage("Something is wrong")
m3.value.message shouldBe UnknownMessage("am I?")
inside(snapshot.unhandled) { case Vector(m1, m2, m3) =>
// reverse order - latest first
m1.value.message shouldBe UnknownMessage("Luke, I'm your father!")
m2.value.message shouldBe UnknownMessage("Something is wrong")
m3.value.message shouldBe UnknownMessage("am I?")
}
snapshot.deadLetters should be(empty)
snapshot.dropped should be(empty)
Expand Down Expand Up @@ -170,8 +169,7 @@ class DeadLettersDataCollectorSpec
}

class BoundedActor extends Actor with RequiresMessageQueue[BoundedMessageQueueSemantics] {
def receive: Receive = {
case _ =>
Thread.sleep(3000)
def receive: Receive = { case _ =>
Thread.sleep(3000)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ActorTreeSpec extends AnyFlatSpec with Matchers {

val tree = ActorTree(
Map(
"user" -> ActorTree(Map("a" -> ActorTree(Map("b" -> ActorTree(Map("c" -> ActorTree(Map.empty))))))),
"user" -> ActorTree(Map("a" -> ActorTree(Map("b" -> ActorTree(Map("c" -> ActorTree(Map.empty))))))),
"system" -> ActorTree(
Map(
"a" -> ActorTree(Map()),
Expand Down
10 changes: 5 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")