Skip to content

Commit

Permalink
Add tpolecat (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcarter97 authored Apr 23, 2022
1 parent 21d8ca5 commit 0e91e4f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
35 changes: 8 additions & 27 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 1 addition & 2 deletions src/main/scala/com/sky/kafka/topicloader/config/config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ 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]

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
}

Expand Down

0 comments on commit 0e91e4f

Please sign in to comment.