KT.UNNECESSARY_ABSTRACT_CLASS

Unnecessary abstract class

This rule inspects abstract classes. In case an abstract class does not have any concrete members it should be refactored into an interface. Abstract classes which do not define any abstract members should instead be refactored into concrete classes.

Noncompliant Code

Copy
abstract class OnlyAbstractMembersInAbstractClass { // violation: no concrete members

    abstract val i: Int
    abstract fun f()
}

abstract class OnlyConcreteMembersInAbstractClass { // violation: no abstract members

    val i: Int = 0
    fun f() { }
}

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