diff --git a/build.sbt b/build.sbt index d987cb6e..0fb825a9 100644 --- a/build.sbt +++ b/build.sbt @@ -26,35 +26,16 @@ crossScalaVersions := supportedScalaVersions semanticdbEnabled := true semanticdbVersion := scalafixSemanticdb.revision -// format: off -ThisBuild / scalacOptions ++= Seq( - "-deprecation", - "-encoding", "utf8", - "-explaintypes", - "-feature", - "-language:existentials", - "-language:higherKinds", - "-unchecked", - "-Xcheckinit", - "-Xfatal-warnings", - "-Xsource:3", - "-Ywarn-dead-code", - "-Ywarn-extra-implicit", - "-Ywarn-numeric-widen", - "-Ywarn-unused:implicits", - "-Ywarn-unused:imports", - "-Ywarn-unused:locals", - "-Ywarn-unused:params", - "-Ywarn-unused:patvars", - "-Ywarn-unused:privates", - "-Ywarn-value-discard" -) ++ { - if (scalaBinaryVersion.value == "2.13") Seq("-Wconf:msg=annotation:silent") - else Seq("-Xfuture", "-Ypartial-unification", "-Yno-adapted-args") +tpolecatScalacOptions ++= Set(ScalacOptions.source3) + +ThisBuild / scalacOptions ++= Seq("-explaintypes") ++ { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, 13)) => Seq("-Wconf:msg=annotation:silent") + case _ => Nil + } } -// format: on -ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0" +ThisBuild / scalafixDependencies += Dependencies.Plugins.organizeImports Test / parallelExecution := false Test / fork := true diff --git a/project/Dependencies.scala b/project/Dependencies.scala index e9058fb1..43d82f79 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,6 +2,10 @@ import sbt._ object Dependencies { + object Plugins { + val organizeImports = "com.github.liancheng" %% "organize-imports" % "0.6.0" + } + object Akka { private val version = "2.6.18" val stream = "com.typesafe.akka" %% "akka-stream" % version diff --git a/project/plugins.sbt b/project/plugins.sbt index 749a0830..7f22a717 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") diff --git a/src/main/scala/com/sky/kafka/topicloader/config/config.scala b/src/main/scala/com/sky/kafka/topicloader/config/config.scala index 52b22230..eab6891f 100644 --- a/src/main/scala/com/sky/kafka/topicloader/config/config.scala +++ b/src/main/scala/com/sky/kafka/topicloader/config/config.scala @@ -5,7 +5,6 @@ import cats.implicits._ import com.typesafe.config.ConfigException import scala.util.Try -import scala.util.control.NonFatal package object config { type ValidationResult[A] = ValidatedNec[ConfigException, A] @@ -13,7 +12,7 @@ package object config { implicit class TryOps[A](t: Try[A]) { private[topicloader] def validate(path: String): ValidationResult[A] = t.toEither.leftMap { case ce: ConfigException => ce - case NonFatal(e) => new ConfigException.BadValue(path, e.getMessage) + case e: Throwable => new ConfigException.BadValue(path, e.getMessage) }.toValidatedNec }