CQM-OverbookedFile

Files should not contain to many classes

Required inputs: RFG

Any file that contains more than 1 classes is a violation of this rule. This does not include nested classes.

Motivation

In the programming languages under consideration, code is always stored in files. The in principle given possibility of storing several classes within a file makes locating classes as well as the selective use of individual classes from such overbooked files more difficult. Ideally each file only contains one public and/or package-visible class.

This rule is based on the CQM Quality Indicator: Überbuchte Datei (p. 300-302).

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

to_many_classes

A maximum of {max_number_of_classes} classes should be defined in one file. {number_of_classes_in_file} are defined in this File.

None

False

Options

count_template_specializations

count_template_specializations : bool = False

Whether specializations of template classes should be counted separately.
 

include_abstract_classes

include_abstract_classes : bool = True

Whether abstract classes should be included.
 

include_structs

include_structs : bool = False

Whether structs should be included.
 

include_template_classes

include_template_classes : bool = True

Whether template classes should be included.
 

max_number_of_classes

max_number_of_classes : int = 1

The maximal number of classes that is allowed in one file.
 

only_count_definitions

only_count_definitions : bool = True

Whether only the definitions of classes should be counted.