VirtusLab / infrastructure-as-types

Infrastructure as Types - modern infrastructure declaration and deployment toolkit
26 stars 3 forks source link

Apply extra scalac options #14

Closed PawelLipski closed 4 years ago

PawelLipski commented 4 years ago

Proposed compiler options from one of my past projects:


  val commonScalacOptions = Seq("-deprecation", "-feature", "-unchecked", "-Xfatal-warnings", "-Ybackend-parallelism", "8")
  val warnScalacOptions = {
    "dead-code extra-implicit inaccessible infer-any"
      .split(" ").map("-Ywarn-" + _)
  }
  val lintScalacOptions = {
    "doc-detached missing-interpolator nullary-override nullary-unit private-shadow stars-align type-parameter-shadow unsound-match"
      .split(" ").map("-Xlint:" + _)
  }
  // partial-unification and scalatest don't like each other, should use them only in prod.
  // At least until this is merged/new release is out: https://github.com/scalatest/scalatest/issues/1165
  val productionOnlyScalacOptions = Seq("-Ywarn-value-discard", "-Ypartial-unification")

  lazy val commonSettings = Seq(
    scalaVersion := "2.12.10",
    scalacOptions ++= commonScalacOptions ++ warnScalacOptions ++ lintScalacOptions,
    scalacOptions in Compile ++= productionOnlyScalacOptions,
......

-Ywarn-value-discard is probably the most important one, it makes spotting e.g. dangling Futures/IOs easier.