KT.ARRAY_PRIMITIVE

Using 'Array' primitive type

Using Array leads to implicit boxing and performance hit. Prefer using Kotlin specialized Array Instances. As stated in the Kotlin documentation Kotlin has specialized arrays to represent primitive types without boxing overhead, such as IntArray, ByteArray and so on.

Noncompliant Code

Copy
fun function(array: Array<Int>) { }
fun returningFunction(): Array<Double> { }

Compliant Code

Copy
fun function(array: IntArray) { }
fun returningFunction(): DoubleArray { }

The content on this page is adapted from the Detekt Docs. Copyright ©2022 The Detekt Team. All rights reserved. https://detekt.dev/comments.html