Skip to content

Improve my car... ehh... sbt #16

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

Merged
merged 15 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
rules = [
NoAutoTupling
RemoveUnused
LeakingImplicitClassVal
NoValInForComprehension
ProcedureSyntax
DisableSyntax
ExplicitResultTypes
Disable
]

ExplicitResultTypes {
unsafeShortenNames = true
}

Disable.ifSynthetic = [
"java/io/Serializable"
"scala/Any"

# when upstream broke noImplicitConversion and we don't agree that their
# implicits are worth the mental burden.
"scala/Option.option2Iterable"
"scala/Predef.any2stringadd"

# I don't understand why these are synthetic
# https://github.com/scalacenter/scalafix/issues/703
{
regex = {
includes = [
"^\\Qscala/collection/MapLike#apply().\\E$"
"^\\Qscala/collection/LinearSeqOptimized#apply().\\E$"
]
}
message = "not a total function"
}
]
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
script: sbt test
-
name: formatting
script: sbt scalafmtCheckAll
script: sbt check
# run ci-release only if previous stages passed
- stage: release
script: sbt ci-release

# These directories are cached to S3 at the end of the build
cache:
directories:
- $HOME/.coursier
- $HOME/.cache/coursier
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
- $HOME/.sbt/launchers
Expand Down
16 changes: 6 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ ThisBuild / homepage := Some(url("https://github.com/avast/scala-server-toolkit"
ThisBuild / description := "Functional programming toolkit for building server applications in Scala."
ThisBuild / licenses := Seq("MIT" -> url("https://raw.githubusercontent.com/avast/scala-server-toolkit/master/LICENSE"))
ThisBuild / developers := List(Developer("jakubjanecek", "Jakub Janecek", "[email protected]", url("https://www.avast.com")))
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/avast/scala-server-toolkit"), "scm:git:[email protected]:avast/scala-server-toolkit.git")
)

ThisBuild / scalaVersion := "2.12.10"
ThisBuild / scalacOptions := ScalacOptions.default

ThisBuild / turbo := true

lazy val commonSettings = Seq(
lazy val commonSettings = BuildSettings.common ++ Seq(
libraryDependencies ++= Seq(
compilerPlugin(Dependencies.kindProjector),
Dependencies.catsEffect,
Dependencies.logbackClassic % Test,
Dependencies.scalaTest % Test
Expand All @@ -33,8 +26,8 @@ lazy val root = project
lazy val example = project
.dependsOn(jvmExecution, http4sBlazeClient, http4sBlazeServer, jvmSsl, jvmSystem, pureconfig)
.enablePlugins(MdocPlugin)
.settings(commonSettings)
.settings(
commonSettings,
name := "scala-server-toolkit-example",
publish / skip := true,
run / fork := true,
Expand Down Expand Up @@ -92,8 +85,11 @@ lazy val jvmSystem = project
)

lazy val pureconfig = project
.settings(commonSettings)
.settings(
commonSettings,
name := "scala-server-toolkit-pureconfig",
libraryDependencies += Dependencies.pureConfig
)

addCommandAlias("check", "; scalafmtSbtCheck; scalafmtCheckAll; compile:scalafix --check ; test:scalafix --check")
addCommandAlias("fix", "; scalafmtSbt; scalafmtAll; compile:scalafix ; test:scalafix")
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.avast.server.toolkit.example.config.Configuration
import com.avast.server.toolkit.execution.ExecutorModule
import com.avast.server.toolkit.pureconfig.PureConfigModule
import com.avast.server.toolkit.system.console.{Console, ConsoleModule}
import com.github.ghik.silencer.silent
import zio.interop.catz._
import zio.{Task, ZIO}

Expand All @@ -15,7 +16,7 @@ object Main extends CatsApp {
def program: Resource[Task, Unit] = {

for {
configuration <- Resource.liftF(PureConfigModule.makeOrRaise[Task, Configuration])
_ <- Resource.liftF(PureConfigModule.makeOrRaise[Task, Configuration])
executorModule <- ExecutorModule.makeFromExecutionContext[Task](runtime.Platform.executor.asEC)
clock = Clock.create[Task]
currentTime <- Resource.liftF(clock.realTime(TimeUnit.MILLISECONDS))
Expand All @@ -26,6 +27,7 @@ object Main extends CatsApp {
} yield ()
}

@silent("dead code") // false positive
override def run(args: List[String]): ZIO[Environment, Nothing, Int] = {
program
.use(_ => Task.never)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, T

import scala.language.higherKinds

@SuppressWarnings(Array("org.wartremover.warts.Null"))
object SslContextModule {

/** Loads [[javax.net.ssl.SSLContext]] and fills it with key/trust managers from the provided config. */
Expand Down
41 changes: 41 additions & 0 deletions project/BuildSettings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import sbt.Keys._
import sbt._
import scalafix.sbt.ScalafixPlugin.autoImport._
import wartremover.WartRemover.autoImport._

object BuildSettings {
lazy val common = Seq(
ThisBuild / scalaVersion := "2.12.10",
libraryDependencies ++= Seq(
compilerPlugin(Dependencies.kindProjector),
compilerPlugin(Dependencies.silencer),
compilerPlugin(scalafixSemanticdb), // for scalafix
Dependencies.silencerLib
),
Compile / compile / wartremoverErrors ++= Warts.all filterNot Set(
Wart.Nothing, // keep, false positives all around
Wart.Overloading,
Wart.Any, // keep, false positives all around
Wart.Equals, // keep, easier that way
Wart.ToString, // keep, easier that way
Wart.Product, // keep, false positives all around
Wart.Serializable, // keep, false positives all around
Wart.DefaultArguments // for constructors for PureConfig
),
ThisBuild / scalafixDependencies ++= Seq(
Dependencies.scalazzi // https://github.com/scalaz/scalazzi
),
scalacOptions ++= Seq(
"-Yrangepos", // for scalafix. required by SemanticDB compiler plugin
"-Ywarn-unused", // for scalafix. not present in sbt-tpolecat for 2.13
"-P:silencer:checkUnused"
),
Test / publishArtifact := false,
Test / test / wartremoverErrors := (Compile / compile / wartremoverErrors).value filterNot Set(
Wart.MutableDataStructures,
Wart.OptionPartial,
Wart.AsInstanceOf,
Wart.EitherProjectionPartial
)
)
}
4 changes: 4 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ object Dependencies {
val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.2.3"
val pureConfig = "com.github.pureconfig" %% "pureconfig" % "0.12.1"
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.8"
val scalazzi = "com.github.vovapolu" %% "scaluzzi" % "0.1.3"
val silencer = "com.github.ghik" % "silencer-plugin" % Versions.silencer cross CrossVersion.full
val silencerLib = "com.github.ghik" % "silencer-lib" % Versions.silencer cross CrossVersion.full
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.28"
val zio = "dev.zio" %% "zio" % "1.0.0-RC13"
val zioInteropCats = "dev.zio" %% "zio-interop-cats" % "2.0.0.0-RC4"

object Versions {

val silencer = "1.4.4"
val http4s = "0.20.11"

}
Expand Down
19 changes: 0 additions & 19 deletions project/ScalacOptions.scala

This file was deleted.

3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.3.4")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.4.31")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.7")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.3")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.8")