List(1).head /* assert: UnsafeIterableOps
^^^^^^^^^^^^
.head is unsafe, consider .headOption */
List(1).tail /* assert: UnsafeIterableOps
^^^^^^^^^^^^
.tail is unsafe, consider .drop(1) */
List(1).minBy(identity) /* assert: UnsafeIterableOps
^^^^^^^^^^^^^
.minBy is unsafe, consider .minByOption */
val x: Option[Boolean] = ???
- x.fold(true)(f)
+ a x.forall(f)
- x.fold(false)(f)
+ x.exists(f)
- name boolean arguments, except in standard functions such as Option#getOrElse
- name arguments in applications with more than X arguments (and sort them alphabetically optionally)
- rewrite trivial cases of UnsafeIterableOps such as
if (xs.empty) None else Some(xs.minBy(f))
, if (xs.size == 1) None else Some(xs.min)
- suspicious sort before fold where the associativity of the operator isn't obvious