Futures are executed in my code and are not being detected.
def f(): Future[String] = {
functionReturningFuture() // How to detect this?
Future("")
}
Ideally, a static analysis tool would help detect this.
Futures are executed in my code and are not being detected.
def f(): Future[String] = {
functionReturningFuture() // How to detect this?
Future("")
}
Ideally, a static analysis tool would help detect this.
The closer you can get is NonUnitStatements
wart from WartRemover, but it cannot error only Future
statements and skip all the others.
The fact that you have such issue could be used as an argument against using Future
and replacing it with some IO: Cats' IO
, Monix's Task
or Scalaz ZIO
. When it comes to them, you build your pipeline first, and the you run it. If you omitted IO
value in return and you didn't compose it into the result in any other way (flatMap
, map2
, for
comprehension etc) it would not get executed - it would still be there but it would cause no harm.
If you wanted to have greater control and error only on Future
, you would probably have to write your own WartRemover's wart or ScalaFix rule.