KT.PROTECTED_MEMBER_IN_FINAL_CLASS

Protected member in final class

Kotlin classes are final by default. Thus classes which are not marked as open should not contain any protected members. Consider using private or internal modifiers instead.

Noncompliant Code

Copy
class ProtectedMemberInFinalClass {
    protected var i = 0
}

Compliant Code

Copy
class ProtectedMemberInFinalClass {
    private var i = 0
}

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