CQM-IncompleteInheritanceField

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

Required inputs: RFG

Multiple fields with the same name 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 and common state sets of subclasses in a common superclass. Despite multiple uses in the subclasses, the inherited behavior and state then only needs to be understood, tested, and maintained once. Since inheritance structures are subject to strong changes, it is often the case that such factorization potentials remain unused: particular in connection with older inheritance structures. 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 (Attribut) (p. 306-308).

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_field

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

None

False

Options

max_number_occurrences

max_number_occurrences : int = 10

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

max_percentage_occurrences

max_percentage_occurrences : float = 50.0

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