如果代码库中有任何未使用的导入,局部或私有变量或无效代码,我试图使编译失败。因此,我添加了以下scalacoptions。
scalacOptions ++= Seq(
"-encoding", "UTF-8",
"-Xfatal-warnings",
"-Xlint:-unused,_",
"-Ywarn-dead-code",
"-Ywarn-unused:imports", // Warn if an import selector is not referenced
"-Ywarn-unused:locals", // Warn if a local definition is unused
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused
"-Ywarn-unused:privates", // Warn if a private member is unused
"-deprecation"
)
但是,每当我编译项目时,它都会编译失败并给出以下错误。
[error] 'imports' is not a valid choice for '-Ywarn-unused'
[error] bad option: '-Ywarn-unused:imports'
scala版本:2.11.11
我不确定我在做什么错误。
答案 0 :(得分:0)
以下设置应该可以使用-
lazy val project_name = project.in(file(".")).settings(commonSettings)
lazy val commonSettings = reformatOnCompileSettings ++ Seq(
scalacOptions ++= Seq(
"-Ywarn-unused-import",
"-language:postfixOps",
"-Ypartial-unification"
)
)
希望这会有所帮助。