From 77ff7ef9e893e565e4ee3bf2851fb6f2040c5fa0 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 6 May 2020 10:16:52 +0200 Subject: [PATCH 1/2] Update scalafmt-core to 2.5.1 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 8f3d05f..329f62d 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "2.4.2" +version = "2.5.1" align.tokens = more align.openParenCallSite = true align.openParenDefnSite = true From 078ad6bc9996909010e266b4f5dc7843a7f6b337 Mon Sep 17 00:00:00 2001 From: Fabian Grutsch Date: Wed, 6 May 2020 17:19:24 +0200 Subject: [PATCH 2/2] update scalafmt and dependencies.scala to work with scala-steward --- .scalafmt.conf | 7 +- .travis.yml | 2 +- project/Dependencies.scala | 68 ++++--------------- project/Publish.scala | 22 +++--- .../query/QueryViewSnapshotSerializer.scala | 9 +-- .../scala/akka/persistence/QueryView.scala | 18 ++--- src/test/scala/com/ovoenergy/UnitSpec.scala | 5 +- .../com/ovoenergy/akka/AkkaFixture.scala | 9 +-- .../akka/AkkaPersistenceFixture.scala | 15 ++-- 9 files changed, 62 insertions(+), 93 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 329f62d..2e9f96c 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,8 +1,7 @@ version = "2.5.1" -align.tokens = more -align.openParenCallSite = true -align.openParenDefnSite = true -danglingParentheses = false + +preset = defaultWithAlign +danglingParentheses.preset = false rewrite.rules = [ SortImports ] diff --git a/.travis.yml b/.travis.yml index 7916057..f90284b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ sudo: required scala: - 2.12.11 - - 2.13.1 + - 2.13.2 jdk: - openjdk8 diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 799f202..e3b9a39 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,62 +3,24 @@ import sbt.librarymanagement.ModuleID object Dependencies { - object akka { - private val version = "2.5.30" - - val actor = "com.typesafe.akka" %% "akka-actor" % version - val slf4j = "com.typesafe.akka" %% "akka-slf4j" % version - val persistence = "com.typesafe.akka" %% "akka-persistence" % version - val protobuf = "com.typesafe.akka" %% "akka-protobuf" % version - val persistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % version - val stream = "com.typesafe.akka" %% "akka-stream" % version - val streamTestKit = "com.typesafe.akka" %% "akka-stream-testkit" % version - } - - object logback { - val classic = "ch.qos.logback" % "logback-classic" % "1.1.8" - } - - object slf4j { - val api = "org.slf4j" % "slf4j-api" % "1.7.30" - } - - object typesafe { - val config = "com.typesafe" % "config" % "1.4.0" - } - - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.8" - val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.3" - - object levelDb { - val levelDb = "org.iq80.leveldb" % "leveldb" % "0.12" - } - - object scalaMock { - val scalaTestSupport = "org.scalamock" %% "scalamock" % "4.4.0" - } - - object scala { - val collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.4" - } + private val akkaVersion = "2.5.30" val core: Seq[ModuleID] = Seq( - akka.actor, - akka.stream, - akka.persistence, - akka.persistenceQuery, - akka.protobuf, - logback.classic, - slf4j.api, - typesafe.config, + "com.typesafe.akka" %% "akka-actor" % akkaVersion, + "com.typesafe.akka" %% "akka-persistence" % akkaVersion, + "com.typesafe.akka" %% "akka-protobuf" % akkaVersion, + "com.typesafe.akka" %% "akka-persistence-query" % akkaVersion, + "com.typesafe.akka" %% "akka-stream" % akkaVersion, + "ch.qos.logback" % "logback-classic" % "1.1.8", + "org.slf4j" % "slf4j-api" % "1.7.30", + "com.typesafe" % "config" % "1.4.0", // -- Testing -- - scalaTest % Test, - scalaCheck % Test, - akka.slf4j % Test, - akka.streamTestKit % Test, - levelDb.levelDb % Test, - scalaMock.scalaTestSupport % Test, + "org.scalatest" %% "scalatest" % "3.1.1" % Test, + "org.scalatestplus" %% "scalacheck-1-14" % "3.1.1.1" % Test, + "com.typesafe.akka" %% "akka-slf4j" % akkaVersion % Test, + "com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test, + "org.iq80.leveldb" % "leveldb" % "0.12" % Test, // -- Backwards Compatibility -- - scala.collectionCompat + "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.4" ) } diff --git a/project/Publish.scala b/project/Publish.scala index 9b7f52a..e6f706d 100644 --- a/project/Publish.scala +++ b/project/Publish.scala @@ -5,11 +5,12 @@ import sbt.plugins._ object NoPublish extends AutoPlugin { override def requires: Plugins = JvmPlugin - override def projectSettings: Seq[Setting[_]] = Seq( - publishArtifact := false, - publish := {}, - publishLocal := {} - ) + override def projectSettings: Seq[Setting[_]] = + Seq( + publishArtifact := false, + publish := {}, + publishLocal := {} + ) } object Publish extends AutoPlugin { @@ -19,9 +20,10 @@ object Publish extends AutoPlugin { override def trigger: PluginTrigger = allRequirements override def requires: Plugins = BintrayPlugin - override def projectSettings: Seq[Setting[_]] = Seq( - bintrayOrganization := Some("firstbird"), - bintrayPackage := "akka-persistence-query-view", - bintrayPackageLabels := Seq("akka", "akka-persistence", "event-sourcing", "cqrs") - ) + override def projectSettings: Seq[Setting[_]] = + Seq( + bintrayOrganization := Some("firstbird"), + bintrayPackage := "akka-persistence-query-view", + bintrayPackageLabels := Seq("akka", "akka-persistence", "event-sourcing", "cqrs") + ) } diff --git a/src/main/scala/akka/contrib/persistence/query/QueryViewSnapshotSerializer.scala b/src/main/scala/akka/contrib/persistence/query/QueryViewSnapshotSerializer.scala index df0f28a..05a74d0 100644 --- a/src/main/scala/akka/contrib/persistence/query/QueryViewSnapshotSerializer.scala +++ b/src/main/scala/akka/contrib/persistence/query/QueryViewSnapshotSerializer.scala @@ -43,10 +43,11 @@ class QueryViewSnapshotSerializer(val system: ExtendedActorSystem) extends BaseS override def toBinary(o: AnyRef, buf: ByteBuffer): Unit = toBinary(o, new ByteBufferOutputStream(buf)) - private def toBinary(o: AnyRef, out: OutputStream): Unit = o match { - case qvs: QueryViewSnapshot[_] => serializeQueryViewSnapshot(qvs, out) - case _ => throw new IllegalArgumentException(s"Can't serialize object of type ${o.getClass}") - } + private def toBinary(o: AnyRef, out: OutputStream): Unit = + o match { + case qvs: QueryViewSnapshot[_] => serializeQueryViewSnapshot(qvs, out) + case _ => throw new IllegalArgumentException(s"Can't serialize object of type ${o.getClass}") + } override def fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef = fromBinary(new ByteArrayInputStream(bytes)) diff --git a/src/main/scala/akka/persistence/QueryView.scala b/src/main/scala/akka/persistence/QueryView.scala index c833ea5..f133b18 100644 --- a/src/main/scala/akka/persistence/QueryView.scala +++ b/src/main/scala/akka/persistence/QueryView.scala @@ -447,19 +447,21 @@ abstract class QueryView () } - override def saveSnapshot(snapshot: Any): Unit = if (!savingSnapshot) { - // Decorate the snapshot - savingSnapshot = true - super.saveSnapshot(QueryViewSnapshot(snapshot, _lastOffset, _sequenceNrByPersistenceId)) - } + override def saveSnapshot(snapshot: Any): Unit = + if (!savingSnapshot) { + // Decorate the snapshot + savingSnapshot = true + super.saveSnapshot(QueryViewSnapshot(snapshot, _lastOffset, _sequenceNrByPersistenceId)) + } private def snapshotSaved(metadata: SnapshotMetadata): Unit = { savingSnapshot = false lastSnapshotSequenceNr = metadata.sequenceNr _noOfEventsSinceLastSnapshot = 0L - log.debug("Snapshot saved successfully snapshotterId={} lastSnapshotSequenceNr={}", - snapshotterId, - lastSnapshotSequenceNr) + log.debug( + "Snapshot saved successfully snapshotterId={} lastSnapshotSequenceNr={}", + snapshotterId, + lastSnapshotSequenceNr) } private def snapshotSavingFailed(error: Throwable): Unit = { diff --git a/src/test/scala/com/ovoenergy/UnitSpec.scala b/src/test/scala/com/ovoenergy/UnitSpec.scala index be4de3e..ba05834 100644 --- a/src/test/scala/com/ovoenergy/UnitSpec.scala +++ b/src/test/scala/com/ovoenergy/UnitSpec.scala @@ -1,11 +1,12 @@ package com.ovoenergy import org.scalatest.concurrent.{ScalaFutures, ScaledTimeSpans} -import org.scalatest.{Matchers, WordSpec} import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec abstract class UnitSpec - extends WordSpec + extends AnyWordSpec with Matchers with ScalaCheckPropertyChecks with ScalaFutures diff --git a/src/test/scala/com/ovoenergy/akka/AkkaFixture.scala b/src/test/scala/com/ovoenergy/akka/AkkaFixture.scala index 519f99e..ded4af0 100644 --- a/src/test/scala/com/ovoenergy/akka/AkkaFixture.scala +++ b/src/test/scala/com/ovoenergy/akka/AkkaFixture.scala @@ -12,10 +12,11 @@ trait AkkaFixture extends BeforeAndAfterEach { self: Suite with ConfigFixture => implicit def system: ActorSystem = Option(_system).getOrElse(throw new IllegalStateException("ActorSystem not yet started")) - def extendedActorSystem: ExtendedActorSystem = system match { - case eas: ExtendedActorSystem => eas - case _ => throw new IllegalStateException("ActorSystem not an instance of ExtendedActorSystem") - } + def extendedActorSystem: ExtendedActorSystem = + system match { + case eas: ExtendedActorSystem => eas + case _ => throw new IllegalStateException("ActorSystem not an instance of ExtendedActorSystem") + } override protected def beforeEach(): Unit = { super.beforeEach() diff --git a/src/test/scala/com/ovoenergy/akka/AkkaPersistenceFixture.scala b/src/test/scala/com/ovoenergy/akka/AkkaPersistenceFixture.scala index b5c7c5f..9a5ea90 100644 --- a/src/test/scala/com/ovoenergy/akka/AkkaPersistenceFixture.scala +++ b/src/test/scala/com/ovoenergy/akka/AkkaPersistenceFixture.scala @@ -84,13 +84,14 @@ trait AkkaPersistenceFixture extends ConfigFixture with ScalaFutures with Before written } - def deleteFromJournal(persistenceId: String, toSequenceNr: Long): Unit = withJournalWriter(persistenceId) { writer => - writer - .ask(DeleteFromJournal(toSequenceNr))(10.seconds) - .mapTo[DeleteMessagesSuccess] - .futureValue(timeout(scaled(5.seconds))) - note(s"Events deleted from $persistenceId up to $toSequenceNr") - } + def deleteFromJournal(persistenceId: String, toSequenceNr: Long): Unit = + withJournalWriter(persistenceId) { writer => + writer + .ask(DeleteFromJournal(toSequenceNr))(10.seconds) + .mapTo[DeleteMessagesSuccess] + .futureValue(timeout(scaled(5.seconds))) + note(s"Events deleted from $persistenceId up to $toSequenceNr") + } override protected def beforeEach(): Unit = { super.beforeEach()