KT.USE_EMPTY_COUNTERPART

Use object's 'empty' initializer

Instantiation of an object's empty state should use the object's empty initializer for clarity purposes.

Noncompliant Code

Copy
arrayOf()
listOf() // or listOfNotNull()
mapOf()
sequenceOf()
setOf()

Compliant Code

Copy
emptyArray()
emptyList()
emptyMap()
emptySequence()
emptySet()

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