CQM-GodNamespace

Namespaces shall not contain too many classes and/or routines

Required inputs: IR, RFG

Any namespace that contains more than 50 classes and routines is a violation of this metric.

Motivation

Packages, directories and namespaces are a means of creating a further abstraction layer within software systems that lies above the level of classes and interfaces. If a package, directory or namespace contains a large number of classes/interfaces, there is a risk that this abstraction can no longer be understood and maintained with a reasonable amount of effort, as the content is too extensive and therefore further decomposition probably seems appropriate.

This rule is based on the CQM Quality Indicator: Gottpaket (p. 204-206).

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_to_big

This namespace contains {val} members, it should contain no more than {max_number_of_members} members.

None

False

Options

allowed_namespaces

allowed_namespaces : set[str] = set()

Namespaces ignored by the rule.
 

count_routines

count_routines : bool = True

Count routines of namespace.
 

count_templates

count_templates : bool = True

Count template classes of namespace.
 

include_anonymous

include_anonymous : bool = False

Whether anonymous namespaces are to be analysed.
 

max_number_of_members

max_number_of_members : int | None = 50

Maximum allowed number of classes and routines in a namespace.