io.github.mkohm.detekt.hint.rules / UseCompositionInsteadOfInheritance

UseCompositionInsteadOfInheritance

class UseCompositionInsteadOfInheritance : Rule

A rule suggesting the use of composition instead of inheritance. It will help you test for Liskov Substitution.

The rule will fire every time inheritance is introduced, unless you derive from a class that exists in a third party package. This will reduce the amount of warnings created where the framework or library are forcing you to introduce inheritance.

Remember to configure this rule correctly by adding: “yourUniquePackageName” : “io.github.mkohm” replacing “io.github.com” with your unique package name.

Constructors

<init> UseCompositionInsteadOfInheritance(config: Config = Config.empty)
A rule suggesting the use of composition instead of inheritance. It will help you test for Liskov Substitution.

Properties

issue val issue: Issue

Functions

visitClass fun visitClass(klass: KtClass): Unit