Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tpolecat #100

Merged
merged 5 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2.3")
bcarter97 marked this conversation as resolved.
Show resolved Hide resolved
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