2

I wanted to use scala-async. I also use Wartremover with [Return] enabled. (http://www.wartremover.org/doc/warts.html#return).

Then I added some code to test it:

async {
  val studentsCount = await(studentsDao.getStudents())
  val externalStudentsCount = await(studentsDao.getExternalStudents())

  externalStudentsCount + studentsCount
}

When I try to compile it, it gives me error:

[wartremover:Return] return is disabled

Is there any way to use Wartremover with scala-async?

Krzysztof Atłasik
  • 21,985
  • 6
  • 54
  • 76

1 Answers1

1

Seems that the async macro generates return statement under the hood.

You can workaround it by adding @SuppressWarnings(Array("org.wartremover.warts.Return")) above the async block.

simpadjo
  • 3,947
  • 1
  • 13
  • 38
  • Adding `@SuppressWarnings` above every `async` block doesn't look very convenient. – Krzysztof Atłasik May 24 '18 at 08:35
  • That's all you can do, I guess. The most convenient is not to use `async` at all but such answer would be off-topic. Wart remover helps to enforce ideomatic code and `async` is not ideomatic itself. – simpadjo May 24 '18 at 08:53
  • 1
    I don't use it, so `no-macros` didn't make it in. That would disable checks in macro expansions. https://github.com/wartremover/wartremover/pull/216 – som-snytt May 24 '18 at 16:53
  • @som-snytt So basically you prepared PR for that, but it was not merged, because it was for wrong branch? – Krzysztof Atłasik May 24 '18 at 19:24
  • Maybe I'll try again; it fell off my radar because the action moved to scalafix for linting. – som-snytt May 25 '18 at 13:39