首页 > 解决方案 > Scala Async 和 Wartrremover

问题描述

我想使用scala-async。我还使用启用了 [Return] 的 Wartrremover。(http://www.wartremover.org/doc/warts.html#return)。

然后我添加了一些代码来测试它:

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

  externalStudentsCount + studentsCount
}

当我尝试编译它时,它给了我错误:

[wartremover:Return] return is disabled

有什么方法可以将 Wartremover 与 scala-async 一起使用?

标签: scalascala-wartremover

解决方案


似乎async宏在幕后生成return语句。

您可以通过在块@SuppressWarnings(Array("org.wartremover.warts.Return"))上方添加来解决它。async


推荐阅读