scalastyle

Simplifying Option[Boolean] expression in Scala

微笑、不失礼 提交于 2021-01-02 07:52:28
问题 I have code like that: optionBoolean.getOrElse(false) && otherOptionBoolean.getOrElse(false) And Scalastyle tells me that it can be simplified. How? 回答1: You can try the following: Seq(optionBoolean, otherOptionBoolean).forall(_.contains(true)) In Scala 2.13 (it is very similar in prior versions) the forall method is located at IterableOnce, and its implementation is: def forall(p: A => Boolean): Boolean = { var res = true val it = iterator while (res && it.hasNext) res = p(it.next()) res }

excluding folder from scalastyle sbt plugin

痴心易碎 提交于 2019-12-11 06:26:11
问题 All the other questions I've found on this topic are quite old. I am building a scala project with sbt and the scala-style plugin but I can't find a way to exclude a specific folder where I have some generated code. Is there a way to force the plugin to not check that particular folder? Right now I am editing the files manually and adding: // scalastyle:off on the top of the file, but this is quite annoying. In the official website http://www.scalastyle.org/sbt.html I couldn't find any