diff --git a/akka-discovery/src/test/scala/akka/discovery/DiscoveryConfigurationSpec.scala b/akka-discovery/src/test/scala/akka/discovery/DiscoveryConfigurationSpec.scala index 8185a96735..997b3bf972 100644 --- a/akka-discovery/src/test/scala/akka/discovery/DiscoveryConfigurationSpec.scala +++ b/akka-discovery/src/test/scala/akka/discovery/DiscoveryConfigurationSpec.scala @@ -143,12 +143,11 @@ class FakeTestDiscovery extends ServiceDiscovery { class FakeTestDiscovery2 extends FakeTestDiscovery -class DiscoveryException(message: String) extends Exception - -class ExceptionThrowingDiscovery extends ServiceDiscovery { - - def lookup(lookup: Lookup, resolveTimeout: FiniteDuration): Future[Resolved] = ??? - - throw new DiscoveryException("Test Exception") +class DiscoveryException(message: String) extends Exception(message) +class ExceptionThrowingDiscovery extends FakeTestDiscovery { + bad() + def bad(): Unit = { + throw new DiscoveryException("oh no") + } } diff --git a/akka-discovery/src/test/scala/akka/discovery/aggregate/AggregateServiceDiscoverySpec.scala b/akka-discovery/src/test/scala/akka/discovery/aggregate/AggregateServiceDiscoverySpec.scala index 7aea4b5bf4..7258430c08 100644 --- a/akka-discovery/src/test/scala/akka/discovery/aggregate/AggregateServiceDiscoverySpec.scala +++ b/akka-discovery/src/test/scala/akka/discovery/aggregate/AggregateServiceDiscoverySpec.scala @@ -8,6 +8,7 @@ import akka.actor.{ ActorSystem, ExtendedActorSystem } import akka.discovery.ServiceDiscovery.{ Resolved, ResolvedTarget } import akka.discovery.{ Discovery, Lookup, ServiceDiscovery } import akka.testkit.TestKit +import akka.util.unused import com.typesafe.config.{ Config, ConfigFactory } import org.scalatest.concurrent.ScalaFutures import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } @@ -16,7 +17,7 @@ import scala.concurrent.Future import scala.concurrent.duration._ import scala.collection.immutable -class StubbedServiceDiscovery(system: ExtendedActorSystem) extends ServiceDiscovery { +class StubbedServiceDiscovery(@unused system: ExtendedActorSystem) extends ServiceDiscovery { override def lookup(query: Lookup, resolveTimeout: FiniteDuration): Future[Resolved] = { if (query.serviceName == "stubbed") { diff --git a/akka-discovery/src/test/scala/akka/discovery/dns/DnsDiscoverySpec.scala b/akka-discovery/src/test/scala/akka/discovery/dns/DnsDiscoverySpec.scala index 574d824032..b3ef3db42b 100644 --- a/akka-discovery/src/test/scala/akka/discovery/dns/DnsDiscoverySpec.scala +++ b/akka-discovery/src/test/scala/akka/discovery/dns/DnsDiscoverySpec.scala @@ -48,7 +48,7 @@ class DnsDiscoverySpec extends AkkaSpec(DnsDiscoverySpec.config) with DockerBind val systemWithAsyncDnsAsResolver = ActorSystem("AsyncDnsSystem", configWithAsyncDnsResolverAsDefault) - private def testSrvRecords(discovery: ServiceDiscovery): Unit = { + private def testSrvRecords(discovery: ServiceDiscovery) = { val name = "_service._tcp.foo.test." def lookup() = @@ -71,7 +71,7 @@ class DnsDiscoverySpec extends AkkaSpec(DnsDiscoverySpec.config) with DockerBind result2.serviceName shouldEqual name } - private def testIpRecords(discovery: ServiceDiscovery): Unit = { + private def testIpRecords(discovery: ServiceDiscovery) = { val name = "a-single.foo.test" val expected = Set(ResolvedTarget("192.168.1.20", None, Some(InetAddress.getByName("192.168.1.20")))) diff --git a/project/AkkaDisciplinePlugin.scala b/project/AkkaDisciplinePlugin.scala index cb1cd96325..376536a775 100644 --- a/project/AkkaDisciplinePlugin.scala +++ b/project/AkkaDisciplinePlugin.scala @@ -19,8 +19,9 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport { override def trigger: PluginTrigger = allRequirements override def requires: Plugins = JvmPlugin && ScalafixPlugin - override lazy val projectSettings = disciplineSettings + + val strictProjects = Set("akka-discovery") lazy val scalaFixSettings = Seq( Compile / scalacOptions += "-Yrangepos") @@ -33,18 +34,21 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport { import sbt.librarymanagement.{ SemanticSelector, VersionNumber } !VersionNumber(scalaVersion.value).matchesSemVer(SemanticSelector("<=2.11.1")) }) - + lazy val disciplineSettings = scalaFixSettings ++ - scoverageSettings ++ Seq( - Compile / scalacOptions ++= disciplineScalacOptions, - Compile / scalacOptions --= undisciplineScalacOptions, + scoverageSettings ++ Seq( + Compile / scalacOptions ++= (if (strictProjects.contains(name.value)) { + disciplineScalacOptions + } else { + disciplineScalacOptions -- undisciplineScalacOptions + }).toSeq, Compile / console / scalacOptions --= Seq("-deprecation", "-Xfatal-warnings", "-Xlint", "-Ywarn-unused:imports"), // Discipline is not needed for the docs compilation run (which uses // different compiler phases from the regular run), and in particular // '-Ywarn-unused:explicits' breaks 'sbt ++2.13.0-M5 akka-actor/doc' // https://github.com/akka/akka/issues/26119 - Compile / doc / scalacOptions --= disciplineScalacOptions, + Compile / doc / scalacOptions --= disciplineScalacOptions.toSeq, Compile / scalacOptions --= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, 13)) => Seq( @@ -66,14 +70,14 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport { /** * Remain visibly filtered for future code quality work and removing. */ - val undisciplineScalacOptions = Seq( + val undisciplineScalacOptions = Set( "-Ywarn-value-discard", "-Ywarn-numeric-widen", "-Yno-adapted-args", "-Xfatal-warnings") /** These options are desired, but some are excluded for the time being*/ - val disciplineScalacOptions = Seq( + val disciplineScalacOptions = Set( // start: must currently remove, version regardless "-Xfatal-warnings", "-Ywarn-value-discard",