2

With a build.sbt file like:

ThisBuild / organization := "com.company"
ThisBuild / version := "1.0.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.11.12"

Global / concurrentRestrictions += Tags.limit(Tags.Test, 1)

Global / scalacOptions ++= Seq("-Ypartial-unification",
                               "-unchecked",
                               "-Xfatal-warnings",
                               "-Ywarn-dead-code",
                               "-Ywarn-inaccessible",
                               "-Ywarn-unused",
                               "-Ywarn-unused-import",
                               "-Ywarn-macros:after")

I get [error] bad option: '-Ywarn-macros:none' after running sbt clean compile

Without -Ywarn-macros:after, the unused import warning raises spurious warnings in files using Circe macros, for example: import io.circe.{ Decoder, Encoder }.

Metropolis
  • 2,018
  • 1
  • 19
  • 36
  • 1
    Do you have an example where you get spurious warnings with circe? – Travis Brown Feb 12 '19 at 22:00
  • 1
    In trying to construct a small example of -Ywarn-unused-import creating a spurious warning when using Circe, I wasn't seeing any such warnings. And now those warnings also are not appearing in my actual project. I suppose sometimes a good night's sleep is the best debugger. – Metropolis Feb 13 '19 at 21:14

1 Answers1

5

-Ywarn-macros wasn't added until Scala 2.12, so the error is expected.

Can you upgrade to Scala 2.12? If you are stuck on 2.11, perhaps you will need to live without -Ywarn-unused-import. (Unused warnings in general have greatly improved as the 2.12.x series has progressed, thanks to tireless work on it by Som Snytt.)

You might be able to confine the Circe-using code to a subproject, and then disable unused warnings in that subproject only, in order to leave them enabled in the rest of your codebase.

Another possibility is to try https://github.com/ghik/silencer.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149