TraversableOnce rewritten as IterableOnceIterableOnce
OndrejSpanel opened this issue · 1 comments
OndrejSpanel commented
A simple source with TravesableOnce results in a strange IterableOnceIterableOnce identifier (the correct identifier is repeated twice):
package com.github.ondrejspanel.scafi
object TraversableOnce {
def shuffle[T](random: scala.util.Random, src: TraversableOnce[T]): List[T] = {
src.foldLeft(List.empty[T]) { (list, item) =>
val len = list.length
val index = (random.nextDouble() * (len + 1)).toInt
list.patch(index, List(item), 0)
}
}
}Using scalafix Collection213Upgrade was rewritten as:
package com.github.ondrejspanel.scafi
import scala.IterableOnce
object TraversableOnce {
def shuffle[T](random: scala.util.Random, src: IterableOnceIterableOnce[T]): List[T] = {
src.foldLeft(List.empty[T]) { (list, item) =>
val len = list.length
val index = (random.nextDouble() * (len + 1)).toInt
list.patch(index, List(item), 0)
}
}
}Complete project available at https://github.com/OndrejSpanel/ScalaFixSimple
SethTisue commented
Note that this is only a "good first issue" for those with an interest in working on the Scalafix rules, as opposed to the main part of the library.