Skip to content

Commit ec97702

Browse files
authored
Merge pull request #16 from sideeffffect
Improve SBT build
2 parents becb92d + f3a3ede commit ec97702

File tree

9 files changed

+96
-32
lines changed

9 files changed

+96
-32
lines changed

.scalafix.conf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
rules = [
2+
NoAutoTupling
3+
RemoveUnused
4+
LeakingImplicitClassVal
5+
NoValInForComprehension
6+
ProcedureSyntax
7+
DisableSyntax
8+
ExplicitResultTypes
9+
Disable
10+
]
11+
12+
ExplicitResultTypes {
13+
unsafeShortenNames = true
14+
}
15+
16+
Disable.ifSynthetic = [
17+
"java/io/Serializable"
18+
"scala/Any"
19+
20+
# when upstream broke noImplicitConversion and we don't agree that their
21+
# implicits are worth the mental burden.
22+
"scala/Option.option2Iterable"
23+
"scala/Predef.any2stringadd"
24+
25+
# I don't understand why these are synthetic
26+
# https://github.com/scalacenter/scalafix/issues/703
27+
{
28+
regex = {
29+
includes = [
30+
"^\\Qscala/collection/MapLike#apply().\\E$"
31+
"^\\Qscala/collection/LinearSeqOptimized#apply().\\E$"
32+
]
33+
}
34+
message = "not a total function"
35+
}
36+
]

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919
script: sbt test
2020
-
2121
name: formatting
22-
script: sbt scalafmtCheckAll
22+
script: sbt check
2323
# run ci-release only if previous stages passed
2424
- stage: release
2525
script: sbt ci-release
2626

2727
# These directories are cached to S3 at the end of the build
2828
cache:
2929
directories:
30-
- $HOME/.coursier
30+
- $HOME/.cache/coursier
3131
- $HOME/.ivy2/cache
3232
- $HOME/.sbt/boot/
3333
- $HOME/.sbt/launchers

build.sbt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@ ThisBuild / homepage := Some(url("https://github.com/avast/scala-server-toolkit"
33
ThisBuild / description := "Functional programming toolkit for building server applications in Scala."
44
ThisBuild / licenses := Seq("MIT" -> url("https://raw.githubusercontent.com/avast/scala-server-toolkit/master/LICENSE"))
55
ThisBuild / developers := List(Developer("jakubjanecek", "Jakub Janecek", "[email protected]", url("https://www.avast.com")))
6-
ThisBuild / scmInfo := Some(
7-
ScmInfo(url("https://github.com/avast/scala-server-toolkit"), "scm:git:[email protected]:avast/scala-server-toolkit.git")
8-
)
9-
10-
ThisBuild / scalaVersion := "2.12.10"
11-
ThisBuild / scalacOptions := ScalacOptions.default
126

137
ThisBuild / turbo := true
148

15-
lazy val commonSettings = Seq(
9+
lazy val commonSettings = BuildSettings.common ++ Seq(
1610
libraryDependencies ++= Seq(
17-
compilerPlugin(Dependencies.kindProjector),
1811
Dependencies.catsEffect,
1912
Dependencies.logbackClassic % Test,
2013
Dependencies.scalaTest % Test
@@ -33,8 +26,8 @@ lazy val root = project
3326
lazy val example = project
3427
.dependsOn(jvmExecution, http4sBlazeClient, http4sBlazeServer, jvmSsl, jvmSystem, pureconfig)
3528
.enablePlugins(MdocPlugin)
29+
.settings(commonSettings)
3630
.settings(
37-
commonSettings,
3831
name := "scala-server-toolkit-example",
3932
publish / skip := true,
4033
run / fork := true,
@@ -92,8 +85,11 @@ lazy val jvmSystem = project
9285
)
9386

9487
lazy val pureconfig = project
88+
.settings(commonSettings)
9589
.settings(
96-
commonSettings,
9790
name := "scala-server-toolkit-pureconfig",
9891
libraryDependencies += Dependencies.pureConfig
9992
)
93+
94+
addCommandAlias("check", "; scalafmtSbtCheck; scalafmtCheckAll; compile:scalafix --check ; test:scalafix --check")
95+
addCommandAlias("fix", "; scalafmtSbt; scalafmtAll; compile:scalafix ; test:scalafix")

example/src/main/scala/com/avast/server/toolkit/example/Main.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.avast.server.toolkit.example.config.Configuration
77
import com.avast.server.toolkit.execution.ExecutorModule
88
import com.avast.server.toolkit.pureconfig.PureConfigModule
99
import com.avast.server.toolkit.system.console.{Console, ConsoleModule}
10+
import com.github.ghik.silencer.silent
1011
import zio.interop.catz._
1112
import zio.{Task, ZIO}
1213

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

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

30+
@silent("dead code") // false positive
2931
override def run(args: List[String]): ZIO[Environment, Nothing, Int] = {
3032
program
3133
.use(_ => Task.never)

jvm-ssl/src/main/scala/com/avast/server/toolkit/ssl/SslContextModule.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, T
1111

1212
import scala.language.higherKinds
1313

14+
@SuppressWarnings(Array("org.wartremover.warts.Null"))
1415
object SslContextModule {
1516

1617
/** Loads [[javax.net.ssl.SSLContext]] and fills it with key/trust managers from the provided config. */

project/BuildSettings.scala

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import sbt.Keys._
2+
import sbt._
3+
import scalafix.sbt.ScalafixPlugin.autoImport._
4+
import wartremover.WartRemover.autoImport._
5+
6+
object BuildSettings {
7+
lazy val common = Seq(
8+
ThisBuild / scalaVersion := "2.12.10",
9+
libraryDependencies ++= Seq(
10+
compilerPlugin(Dependencies.kindProjector),
11+
compilerPlugin(Dependencies.silencer),
12+
compilerPlugin(scalafixSemanticdb), // for scalafix
13+
Dependencies.silencerLib
14+
),
15+
Compile / compile / wartremoverErrors ++= Warts.all filterNot Set(
16+
Wart.Nothing, // keep, false positives all around
17+
Wart.Overloading,
18+
Wart.Any, // keep, false positives all around
19+
Wart.Equals, // keep, easier that way
20+
Wart.ToString, // keep, easier that way
21+
Wart.Product, // keep, false positives all around
22+
Wart.Serializable, // keep, false positives all around
23+
Wart.DefaultArguments // for constructors for PureConfig
24+
),
25+
ThisBuild / scalafixDependencies ++= Seq(
26+
Dependencies.scalazzi // https://github.com/scalaz/scalazzi
27+
),
28+
scalacOptions ++= Seq(
29+
"-Yrangepos", // for scalafix. required by SemanticDB compiler plugin
30+
"-Ywarn-unused", // for scalafix. not present in sbt-tpolecat for 2.13
31+
"-P:silencer:checkUnused"
32+
),
33+
Test / publishArtifact := false,
34+
Test / test / wartremoverErrors := (Compile / compile / wartremoverErrors).value filterNot Set(
35+
Wart.MutableDataStructures,
36+
Wart.OptionPartial,
37+
Wart.AsInstanceOf,
38+
Wart.EitherProjectionPartial
39+
)
40+
)
41+
}

project/Dependencies.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ object Dependencies {
1010
val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.2.3"
1111
val pureConfig = "com.github.pureconfig" %% "pureconfig" % "0.12.1"
1212
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.8"
13+
val scalazzi = "com.github.vovapolu" %% "scaluzzi" % "0.1.3"
14+
val silencer = "com.github.ghik" % "silencer-plugin" % Versions.silencer cross CrossVersion.full
15+
val silencerLib = "com.github.ghik" % "silencer-lib" % Versions.silencer cross CrossVersion.full
1316
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.28"
1417
val zio = "dev.zio" %% "zio" % "1.0.0-RC13"
1518
val zioInteropCats = "dev.zio" %% "zio-interop-cats" % "2.0.0.0-RC4"
1619

1720
object Versions {
1821

22+
val silencer = "1.4.4"
1923
val http4s = "0.20.11"
2024

2125
}

project/ScalacOptions.scala

Lines changed: 0 additions & 19 deletions
This file was deleted.

project/plugins.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.3.4")
33
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.4.31")
44
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
55
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2")
6+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.7")
7+
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.3")
8+
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.8")

0 commit comments

Comments
 (0)