This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 34478576 fix: fix compilation warnings across all Scala versions (#555)
34478576 is described below

commit 34478576820213bb95583c10f019d845aa86e975
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Mon Jul 6 16:23:46 2026 +0800

    fix: fix compilation warnings across all Scala versions (#555)
    
    * fix: fix compilation warnings across all Scala versions
    
    Motivation:
    Compilation produced 20 warnings in Scala 2.13 and 5 warnings in Scala 
3.8.4:
    - Unused local vals in documentation snippet files
    - False positive "possible missing interpolator" on HOCON config strings
    - Unused parameters and pattern variables in test code
    - Non-exhaustive match expressions in test code
    - Deprecated `x: _*` vararg splice syntax in Scala 3
    
    Modification:
    - Add @nowarn annotations for unused vals in ScaladslSnippets (core and 
state)
    - Add @nowarn annotations for HOCON config strings in TablesTestSpec and 
PekkoPersistenceConfigTest
    - Replace unused parameters with _ in EventsByInfrequentTagTest
    - Add wildcard cases to non-exhaustive matches in 
CurrentEventsByPersistenceIdTest, EventsByPersistenceIdTest, and 
EventAdapterTest
    - Replace Vector(range: _*) with range.toVector in JdbcJournalPerfSpec
    - Replace Set(tags: _*) with tags.toSet in QueryTestSpec
    - Add -Wconf for vararg splice deprecation in Scala 3 build config
    
    Result:
    Clean compilation with zero warnings across all Scala versions.
    
    Tests:
    sbt +test:compile - all versions pass with no warnings
    
    References:
    None - code quality improvement
    
    * fix: move @nowarn annotations to object level for cleaner docs
    
    Address review feedback: move @nowarn("msg=is never used") from
    individual methods to the enclosing object in ScaladslSnippets
    to avoid noise in generated documentation snippets.
---
 .../scala/org/apache/pekko/persistence/jdbc/ScaladslSnippets.scala     | 2 ++
 .../test/scala/org/apache/pekko/persistence/jdbc/TablesTestSpec.scala  | 3 +++
 .../persistence/jdbc/configuration/PekkoPersistenceConfigTest.scala    | 2 ++
 .../apache/pekko/persistence/jdbc/journal/JdbcJournalPerfSpec.scala    | 2 +-
 .../persistence/jdbc/query/CurrentEventsByPersistenceIdTest.scala      | 1 +
 .../org/apache/pekko/persistence/jdbc/query/EventAdapterTest.scala     | 1 +
 .../pekko/persistence/jdbc/query/EventsByPersistenceIdTest.scala       | 1 +
 .../scala/org/apache/pekko/persistence/jdbc/query/QueryTestSpec.scala  | 2 +-
 .../org/apache/pekko/persistence/jdbc/state/ScaladslSnippets.scala     | 2 ++
 project/ProjectAutoPlugin.scala                                        | 3 ++-
 10 files changed, 16 insertions(+), 3 deletions(-)

diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/ScaladslSnippets.scala 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/ScaladslSnippets.scala
index 36889f54..a9c4d941 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/ScaladslSnippets.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/ScaladslSnippets.scala
@@ -20,8 +20,10 @@ import pekko.actor.ActorSystem
 import pekko.persistence.jdbc.query.scaladsl.JdbcReadJournal
 import pekko.persistence.jdbc.testkit.scaladsl.SchemaUtils
 
+import scala.annotation.nowarn
 import scala.concurrent.Future
 
+@nowarn("msg=is never used")
 object ScaladslSnippets {
 
   def create(): Unit = {
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/TablesTestSpec.scala 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/TablesTestSpec.scala
index 38653361..afc60a01 100644
--- a/core/src/test/scala/org/apache/pekko/persistence/jdbc/TablesTestSpec.scala
+++ b/core/src/test/scala/org/apache/pekko/persistence/jdbc/TablesTestSpec.scala
@@ -19,9 +19,12 @@ import org.apache.pekko.persistence.jdbc.config.{ 
JournalConfig, ReadJournalConf
 import org.scalatest.flatspec.AnyFlatSpec
 import org.scalatest.matchers.should.Matchers
 
+import scala.annotation.nowarn
+
 abstract class TablesTestSpec extends AnyFlatSpec with Matchers {
   def toColumnName[A](tableName: String)(columnName: String): String = 
s"$tableName.$columnName"
 
+  @nowarn("msg=possible missing interpolator")
   val config = ConfigFactory
     .parseString("""
       |pekko-persistence-jdbc.slick.db {
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/configuration/PekkoPersistenceConfigTest.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/configuration/PekkoPersistenceConfigTest.scala
index b3f4d1ed..87ca6d0d 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/configuration/PekkoPersistenceConfigTest.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/configuration/PekkoPersistenceConfigTest.scala
@@ -19,11 +19,13 @@ import org.apache.pekko.persistence.jdbc.config.{ 
JournalConfig, ReadJournalConf
 import org.scalatest.flatspec.AnyFlatSpec
 import org.scalatest.matchers.should.Matchers
 
+import scala.annotation.nowarn
 import scala.concurrent.duration._
 
 class PekkoPersistenceConfigTest extends AnyFlatSpec with Matchers {
   private val referenceConfig: Config = ConfigFactory.load("reference")
 
+  @nowarn("msg=possible missing interpolator")
   val config: Config = ConfigFactory
     .parseString("""
           |pekko-persistence-jdbc.slick.db {
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalPerfSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalPerfSpec.scala
index 96d01a69..b0314397 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalPerfSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalPerfSpec.scala
@@ -68,7 +68,7 @@ abstract class JdbcJournalPerfSpec(config: Config, 
schemaType: SchemaType)
 
   def actorCount = 100
 
-  private val commands = Vector(1 to eventsCount: _*)
+  private val commands = (1 to eventsCount).toVector
 
   "A PersistentActor's performance" must {
     s"measure: persist()-ing $eventsCount events for $actorCount actors" in {
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/CurrentEventsByPersistenceIdTest.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/CurrentEventsByPersistenceIdTest.scala
index efc45ca4..f8413d43 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/CurrentEventsByPersistenceIdTest.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/CurrentEventsByPersistenceIdTest.scala
@@ -137,6 +137,7 @@ abstract class CurrentEventsByPersistenceIdTest(config: 
String) extends QueryTes
         val env3 = tp.expectNext(ExpectNextTimeout)
         val ordering3 = env3.offset match {
           case Sequence(value) => value
+          case other           => fail(s"Expected Sequence offset, got $other")
         }
 
         val env6 = tp.expectNext(ExpectNextTimeout)
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventAdapterTest.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventAdapterTest.scala
index 320218b5..e0a88a97 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventAdapterTest.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventAdapterTest.scala
@@ -40,6 +40,7 @@ object EventAdapterTest {
     override def fromJournal(event: Any, manifest: String): EventSeq =
       event match {
         case e: EventAdapted => EventSeq.single(e.restored)
+        case _               => EventSeq.single(event)
       }
   }
 
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventsByPersistenceIdTest.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventsByPersistenceIdTest.scala
index c24bc2bb..b21bea07 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventsByPersistenceIdTest.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/EventsByPersistenceIdTest.scala
@@ -152,6 +152,7 @@ abstract class EventsByPersistenceIdTest(config: String) 
extends QueryTestSpec(c
         val env3 = tp.expectNext(ExpectNextTimeout)
         val ordering3 = env3.offset match {
           case Sequence(value) => value
+          case other           => fail(s"Expected Sequence offset, got $other")
         }
 
         actor2 ! withTags(4, "ordering")
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/QueryTestSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/QueryTestSpec.scala
index 4a75ba2b..2afa0e98 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/QueryTestSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/query/QueryTestSpec.scala
@@ -343,7 +343,7 @@ abstract class QueryTestSpec(config: String, 
configOverrides: Map[String, Config
     Future.sequence(refs.map(_ ? "state")).futureValue
   }
 
-  def withTags(payload: Any, tags: String*) = Tagged(payload, Set(tags: _*))
+  def withTags(payload: Any, tags: String*) = Tagged(payload, tags.toSet)
 
   def withDao(f: JournalDao => Unit)(implicit system: ActorSystem, ec: 
ExecutionContext, mat: Materializer): Unit = {
     val fqcn: String = journalConfig.pluginConfig.dao
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/state/ScaladslSnippets.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/state/ScaladslSnippets.scala
index 6d0c2aaf..288c71a6 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/state/ScaladslSnippets.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/state/ScaladslSnippets.scala
@@ -9,6 +9,7 @@
 
 package org.apache.pekko.persistence.jdbc.state
 
+import scala.annotation.nowarn
 import scala.concurrent.{ ExecutionContext, Future }
 import org.apache.pekko
 import pekko.actor.ActorSystem
@@ -16,6 +17,7 @@ import pekko.Done
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.matchers.should.Matchers
 
+@nowarn("msg=is never used")
 object ScaladslSnippets extends ScalaFutures with Matchers {
 
   def create(): Unit = {
diff --git a/project/ProjectAutoPlugin.scala b/project/ProjectAutoPlugin.scala
index 67cac780..de79d2fc 100644
--- a/project/ProjectAutoPlugin.scala
+++ b/project/ProjectAutoPlugin.scala
@@ -59,7 +59,8 @@ object ProjectAutoPlugin extends AutoPlugin {
             "-Wconf:msg=is deprecated for wildcard arguments of types:s",
             "-Wconf:msg=The trailing ` _` for eta-expansion is unnecessary:s",
             "-Wconf:msg=with as a type operator has been deprecated:s",
-            "-Wconf:msg=Unreachable case except for null:s") ++
+            "-Wconf:msg=Unreachable case except for null:s",
+            "-Wconf:msg=is no longer supported for vararg splices:s") ++
           (if (CrossVersion.partialVersion(scalaVersion.value).exists(_._2 < 
9))
              Seq("-Yfuture-lazy-vals", "-Wconf:msg=bad 
option.*-Yfuture-lazy-vals:s")
            else Seq.empty)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to