QuackatronHQ / Gigarepo

Consider rewriting filter().headOption as find() SC-P1006
Anti-pattern
Major
1 occurrence in this check
Consider rewriting filter().headOption as find()
23
24  def pickFirst1(arr: Array[Int], criteria: Int => Boolean): Int           = arr.filter(criteria).head
25  def pickFirst2(arr: Array[Int], criteria: Int => Boolean): Option[Int]   =
26    arr.filter(criteria).headOption27  def pickInAnOrder(arr: Array[Int], criteria: Int => Boolean): Array[Int] =
28    arr.sortWith(_ < _).filter(criteria)
29