KT.SERIAL_VERSION_U_I_D_IN_SERIALIZABLE_CLASS

Serializable class does not declare a correct serialVersionUID

Classes which implement the Serializable interface should also correctly declare a serialVersionUID. This rule verifies that a serialVersionUID was correctly defined.

Noncompliant Code

Copy
class IncorrectSerializable : Serializable {

    companion object {
        val serialVersionUID = 1 // wrong declaration for UID
    }
}

Compliant Code

Copy
class CorrectSerializable : Serializable {

    companion object {
        const val serialVersionUID = 1L
    }
}

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