CQM-NamespaceHierarchyBreakUp

The classes hierarchy should not run against the namespace hierarchy

Required inputs: RFG

Every class inside a namespace N that inherits from a class inside a namespace that is enclosed by N is a violation of this rule.

Motivation

The hierarchy imposed by the division into namespaces suggests that inheritance relationships should only run between namespaces at the same level or from a namespace at a outer level to a namespace at a inner level. A class OC from a outer-namespace ON is not expected to inherit from a class IC from a inner-namespace IN, so comprehensibility is hampered because two directions of specialization are orthogonal here. Such an inheritance relationship could be a sign of bad namespace hierarchies.

This rule is based on the CQM Quality Indicator: Pakethierarchieaufbruch (p. 261-263).

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

namespace_hierarchy_breakup

This class’s namespace encloses the namespace of its superclass.

None

False

Options

include_template_classes

include_template_classes : bool = True

Whether template classes are to be analyzed.