Skip to content

Commit 3a90e5d

Browse files
committed
pimp my sbt
1 parent 317b110 commit 3a90e5d

File tree

8 files changed

+109
-38
lines changed

8 files changed

+109
-38
lines changed

.scalafix.conf

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

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ before_install:
1010
stages:
1111
- name: test
1212
- name: release
13-
if: ((branch = master AND type = push) OR (tag IS present)) AND NOT fork
13+
if: ((branch = master) OR (tag IS present)) AND NOT fork
1414

1515
jobs:
1616
include:
@@ -19,7 +19,7 @@ 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

build.sbt

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,62 @@
1+
addCommandAlias("check", "; scalafmtSbtCheck; scalafmtCheckAll; compile:scalafix --check ; test:scalafix --check")
2+
addCommandAlias("fix", "; scalafmtSbt; scalafmtAll; compile:scalafix ; test:scalafix")
3+
14
ThisBuild / organization := "com.avast"
25
ThisBuild / homepage := Some(url("https://github.com/avast/scala-server-toolkit"))
36
ThisBuild / description := "Functional programming toolkit for building server applications in Scala."
47
ThisBuild / licenses := Seq("MIT" -> url("https://raw.githubusercontent.com/avast/scala-server-toolkit/master/LICENSE"))
58
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-
)
99

1010
ThisBuild / scalaVersion := "2.13.0"
11-
ThisBuild / scalacOptions := ScalacOptions.default
1211

1312
ThisBuild / turbo := true
1413

1514
lazy val commonSettings = Seq(
1615
libraryDependencies ++= Seq(
1716
compilerPlugin(Dependencies.kindProjector),
17+
compilerPlugin(Dependencies.betterMonadicFor),
18+
compilerPlugin(Dependencies.silencer),
19+
compilerPlugin(scalafixSemanticdb), // for scalafix
20+
Dependencies.silencerLib,
1821
Dependencies.catsEffect,
19-
Dependencies.scalaTest
22+
Dependencies.scalaTest % Test
23+
),
24+
Compile / compile / wartremoverErrors ++= Warts.all filterNot Set(
25+
Wart.Nothing, // keep, false positives all around
26+
Wart.Overloading,
27+
Wart.Any, // keep, false positives all around
28+
Wart.Equals, // keep, easier that way
29+
Wart.ToString, // keep, easier that way
30+
Wart.Product, // keep, false positives all around
31+
Wart.Serializable // keep, false positives all around
2032
),
21-
Test / publishArtifact := false
33+
ThisBuild / scalafixDependencies ++= Seq(
34+
Dependencies.scalazzi // https://github.com/scalaz/scalazzi
35+
),
36+
scalacOptions ++= Seq(
37+
"-Yrangepos", // for scalafix. required by SemanticDB compiler plugin
38+
"-Ywarn-unused", // for scalafix. not present in sbt-tpolecat for 2.13
39+
"-P:silencer:checkUnused"
40+
),
41+
scalacOptions --= {
42+
if (!sys.env.contains("TRAVIS"))
43+
Seq(
44+
"-Xfatal-warnings" // for scala-fix https://scalacenter.github.io/scalafix/docs/rules/RemoveUnused.html
45+
)
46+
else
47+
Seq()
48+
},
49+
Test / publishArtifact := false,
50+
Test / test / wartremoverErrors := (Compile / compile / wartremoverErrors).value filterNot Set(
51+
Wart.MutableDataStructures,
52+
Wart.OptionPartial,
53+
Wart.AsInstanceOf,
54+
Wart.EitherProjectionPartial
55+
)
2256
)
2357

24-
lazy val root = (project in file("."))
58+
lazy val root = project
59+
.in(file("."))
2560
.aggregate(example, pureconfig)
2661
.settings(
2762
name := "scala-server-toolkit",
@@ -31,8 +66,8 @@ lazy val root = (project in file("."))
3166
lazy val example = project
3267
.dependsOn(pureconfig)
3368
.enablePlugins(MdocPlugin)
69+
.settings(commonSettings)
3470
.settings(
35-
commonSettings,
3671
name := "scala-server-toolkit-example",
3772
publish / skip := true,
3873
run / fork := true,
@@ -46,8 +81,8 @@ lazy val example = project
4681
)
4782

4883
lazy val pureconfig = project
84+
.settings(commonSettings)
4985
.settings(
50-
commonSettings,
5186
name := "scala-server-toolkit-pureconfig",
5287
libraryDependencies += Dependencies.pureConfig
5388
)

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
@@ -3,17 +3,19 @@ package com.avast.server.toolkit.example
33
import cats.effect.Resource
44
import com.avast.server.toolkit.example.config.Configuration
55
import com.avast.server.toolkit.pureconfig.PureConfigModule
6+
import com.github.ghik.silencer.silent
67
import zio.interop.catz._
78
import zio.{Task, ZIO}
89

910
object Main extends CatsApp {
1011

1112
def program: Resource[Task, Unit] = {
1213
for {
13-
configuration <- Resource.liftF(PureConfigModule.makeOrRaise[Task, Configuration])
14+
_ <- Resource.liftF(PureConfigModule.makeOrRaise[Task, Configuration])
1415
} yield ()
1516
}
1617

18+
@silent("dead code")
1719
override def run(args: List[String]): ZIO[Environment, Nothing, Int] = {
1820
program
1921
.use(_ => Task.never)

project/Dependencies.scala

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,26 @@ import sbt._
22

33
object Dependencies {
44

5-
val catsEffect = "org.typelevel" %% "cats-effect" % "2.0.0"
6-
val kindProjector = "org.typelevel" %% "kind-projector" % "0.10.3"
7-
val pureConfig = "com.github.pureconfig" %% "pureconfig" % "0.12.0"
8-
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.8" % Test
9-
val zio = "dev.zio" %% "zio" % "1.0.0-RC13"
10-
val zioInteropCats = "dev.zio" %% "zio-interop-cats" % "2.0.0.0-RC4"
5+
object Versions {
6+
val catsEffect = "2.0.0"
7+
val kindProjector = "0.10.3"
8+
val pureConfig = "0.12.0"
9+
val scalaTest = "3.0.8"
10+
val zio = "1.0.0-RC13"
11+
val zioInteropCats = "2.0.0.0-RC4"
12+
val silencer = "1.4.3"
13+
val scalazzi = "0.1.3"
14+
val betterMonadicFor = "0.3.1"
15+
}
1116

17+
val catsEffect = "org.typelevel" %% "cats-effect" % Versions.catsEffect
18+
val kindProjector = "org.typelevel" %% "kind-projector" % Versions.kindProjector
19+
val pureConfig = "com.github.pureconfig" %% "pureconfig" % Versions.pureConfig
20+
val scalaTest = "org.scalatest" %% "scalatest" % Versions.scalaTest
21+
val zio = "dev.zio" %% "zio" % Versions.zio
22+
val zioInteropCats = "dev.zio" %% "zio-interop-cats" % Versions.zioInteropCats
23+
val silencer = "com.github.ghik" % "silencer-plugin" % Versions.silencer cross CrossVersion.full
24+
val silencerLib = "com.github.ghik" % "silencer-lib" % Versions.silencer cross CrossVersion.full
25+
val scalazzi = "com.github.vovapolu" %% "scaluzzi" % Versions.scalazzi
26+
val betterMonadicFor = "com.olegpy" %% "better-monadic-for" % Versions.betterMonadicFor
1227
}

project/ScalacOptions.scala

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

project/plugins.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.3.2")
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")
9+
addSbtPlugin("com.github.tkawachi" % "sbt-lock" % "0.6.1")

pureconfig/src/main/scala/com/avast/server/toolkit/pureconfig/PureConfigModule.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import cats.syntax.either._
66
import pureconfig.error.{ConfigReaderFailure, ConfigReaderFailures, ConvertFailure}
77
import pureconfig.{ConfigReader, ConfigSource}
88

9-
import scala.language.higherKinds
109
import scala.reflect.ClassTag
1110

1211
/** Provides loading of configuration into case class via PureConfig. */

0 commit comments

Comments
 (0)