eygraber
02/07/2024, 5:37 PMusers.map { it.name }.toTypedArray()) fit in detekt's rule sets or is it something that should be kept 3rd party?ephemient
02/07/2024, 5:46 PM.map is necessary if it's not a List and .map is desirable if it's not a RandomAccessList, which may be context that even Detekt with type resolution doesn't knoweygraber
02/07/2024, 5:47 PMList came from, and only raise a violation if it can determine where it came from and that it is a RandomAccessList but that seems like a loteygraber
02/07/2024, 5:48 PMephemient
02/07/2024, 5:52 PMinline fun <T, reified R> Iterable<T>.mapToTypedArray(block: (T) -> R): Array<R> =
if (this is List<T> && this is RandomAccess) {
Array(this.size) { block(this[it]) }
} else {
this.map(block).toTypedArray()
}
and write a rule suggesting that, but I think it comes up pretty rarely so idkBrais Gabin
02/07/2024, 6:48 PMBrais Gabin
02/07/2024, 6:50 PM