Don't warn about discarded return values (#28403)

* Since we have and use many API's where the return value can be safely
ignored.
* akka-cluster-sharding also does implicit widening
This commit is contained in:
Arnout Engelen 2020-01-22 05:47:18 +01:00 committed by Helena Edelson
parent a9750b3c37
commit ef08d9fe5c

View file

@ -19,7 +19,29 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
// We allow warnings in docs to get the 'snippets' right // We allow warnings in docs to get the 'snippets' right
val nonFatalWarningsFor = Set("akka-docs") val nonFatalWarningsFor = Set("akka-docs")
val strictProjects = Set("akka-discovery", "akka-protobuf", "akka-coordination") val looseProjects = Set(
"akka-actor",
"akka-actor-testkit-typed",
"akka-actor-tests",
"akka-actor-typed",
"akka-actor-typed-tests",
"akka-bench-jmh",
"akka-cluster",
"akka-cluster-metrics",
"akka-cluster-sharding",
"akka-distributed-data",
"akka-persistence",
"akka-persistence-tck",
"akka-persistence-typed",
"akka-persistence-query",
"akka-remote",
"akka-remote-tests",
"akka-stream",
"akka-stream-testkit",
"akka-stream-tests",
"akka-stream-tests-tck",
"akka-testkit",
)
lazy val scalaFixSettings = Seq(Compile / scalacOptions += "-Yrangepos") lazy val scalaFixSettings = Seq(Compile / scalacOptions += "-Yrangepos")
@ -54,8 +76,8 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
Nil Nil
}).toSeq, }).toSeq,
Compile / scalacOptions --= Compile / scalacOptions --=
(if (strictProjects.contains(name.value)) Seq.empty (if (looseProjects.contains(name.value)) undisciplineScalacOptions.toSeq
else undisciplineScalacOptions.toSeq), else Seq.empty),
// Discipline is not needed for the docs compilation run (which uses // Discipline is not needed for the docs compilation run (which uses
// different compiler phases from the regular run), and in particular // different compiler phases from the regular run), and in particular
// '-Ywarn-unused:explicits' breaks 'sbt ++2.13.0-M5 akka-actor/doc' // '-Ywarn-unused:explicits' breaks 'sbt ++2.13.0-M5 akka-actor/doc'
@ -65,22 +87,18 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
Compile / console / scalacOptions --= disciplineScalacOptions.toSeq) Compile / console / scalacOptions --= disciplineScalacOptions.toSeq)
val testUndicipline = Seq( val testUndicipline = Seq(
"-Ywarn-dead-code", // ??? used in compile only specs "-Ywarn-dead-code", // '???' used in compile only specs
"-Ywarn-value-discard" // Ignoring returned assertions
) )
/** /**
* Remain visibly filtered for future code quality work and removing. * Remain visibly filtered for future code quality work and removing.
*/ */
val undisciplineScalacOptions = Set("-Ywarn-value-discard", "-Ywarn-numeric-widen") val undisciplineScalacOptions = Set("-Ywarn-numeric-widen")
/** These options are desired, but some are excluded for the time being*/ /** These options are desired, but some are excluded for the time being*/
val disciplineScalacOptions = Set( val disciplineScalacOptions = Set(
// start: must currently remove, version regardless
"-Ywarn-value-discard",
"-Ywarn-numeric-widen", "-Ywarn-numeric-widen",
"-Yno-adapted-args", "-Yno-adapted-args",
// end
"-deprecation", "-deprecation",
"-Xlint", "-Xlint",
"-Ywarn-dead-code", "-Ywarn-dead-code",