scalafix-noinfer is a Scalafix rule to warn about undesired type inference. It
offers a replacement for the NoInfer
rule that was built into Scalafix 0.5.
See the blog post stricter Scala with -Xlint, -Xfatal-warnings, and Scalafix.
In a project with Scalafix enabled (0.9.0 or later):
ThisBuild / scalafixDependencies +=
"com.eed3si9n.fix" %% "scalafix-noinfer" % "0.1.0-M1"
lazy val root = (project in file(".")).
settings(
name := "hello",
addCompilerPlugin(scalafixSemanticdb),
scalacOptions ++= List(
"-P:semanticdb:synthetics:on",
"-Yrangepos",
),
)
rules = [
NoInfer
]
Run scalafix
or scalafix NoInfer
with sbt.
By default this rule forbids the inference of scala.Any
, scala.AnyVal
,
java.io.Serializable
, scala.Serializable
, and scala.Product
. You can
customize this using .scalafix.conf
as follows:
rules = [
NoInfer
]
NoInfer.disabledTypes = [
scala.Any
scala.AnyVal
scala.Serializable
java.io.Serializable
scala.Product
scala.Predef.any2stringadd
]
Apache-2.0