CQM-IncompleteInheritanceRoutine

Multiple subclasses contain the same routine, which does not exist in their superclass

Required inputs: IR

Multiple routines with the same signature exists in at least 10 or more than 50.0 percent of direct subclasses but not in the superclass. Only for superclasses with at least 2 subclasses.

Motivation

A powerful way of inheritance is to factor out common behavior of subclasses into a common superclass. Despite the multiple use in the subclasses, the behavior then only needs to be understood, tested and maintained once. Since inheritance structures are subject however to strong changes, it comes in particular with older inheritance structures that such factorization potentials remain unused. The result is redundant implementations with multiple efforts for testing, maintenance and understanding.

This rule is based on the CQM Quality Indicator: unvollständige Vererbung (Methode) (p. 309-311).

Reference

Simon, Frank/ Seng, Olaf/ Mohaupt, Thomas (2006): Code-Quality-Management: Technische Qualität industrieller Softwaresysteme transparent und vergleichbar gemacht, 1st ed., Heidelberg, Germany: dpunkt.verlag GmbH.

Possible Messages

Key

Text

Severity

Disabled

incomplete_inheritance_routine

This routine exists in a large number of subclasses, but not the superclass.

None

False

Options

max_number_occurrences

max_number_occurrences : int = 10

Maximal number of routines with the same signature allowed across subclasses. This option is related to max_percentage_occurrences. If routines with the same signature are found in more than max_percentage_occurrences percent of subclasses OR there are more than max_number_occurrences of routines with the same signature, it is a violation.
 

max_percentage_occurrences

max_percentage_occurrences : float = 50.0

Maximal percentile of subclasses allowed to contain a routine with the same signature. Needs at least 2 subclasses. This option is related to max_number_occurrences. If routines with the same signature are found in more than max_percentage_occurrences percent of subclasses OR there are more than max_number_occurrences of routines with the same signature, it is a violation.