CQM-Classlet

Classes shall not have too few data members and/or routines

Required inputs: RFG

Any class that contains less than 3 data members or less than 3 routines is a violation of this rule.

Motivation

In the case of very small classes, the question arises whether this class is really useful or if it should not better be merged with another class. Often, classlets are created by moving functionality to other classes, but the class itself is not dissolved accordingly. A class that is too small represents an unnecessary abstraction that is more of a hindrance to understanding the system. Understanding becomes more difficult the more classlets are in the system.

This rule is based on the CQM Quality Indicator: Klässchen (p. 228-230).

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_few_members_and

This class contains {routines} routines and {members} data members, it should at least contain {min_number_of_routines} routines and {min_number_of_members} data members.

None

False

to_few_members_or

This class contains {routines} routines and {members} data members, it should at least contain {min_number_of_routines} routines or {min_number_of_members} data members.

None

False

Options

count_constructors

count_constructors : bool = False

Count constructors of class.
 

count_deleted

count_deleted : bool = True

Count deleted routines of class.
 

count_destructors

count_destructors : bool = False

Count destructors of class.
 

count_operators

count_operators : bool = True

Count operators of class.
 

count_private

count_private : bool = True

Count private members of class.
 

count_protected

count_protected : bool = True

Count protected members of class.
 

count_public

count_public : bool = True

Count public members of class.
 

count_routines_and_attributes_separate

count_routines_and_attributes_separate : bool = False

Whether routines and attributes should count separate or together.
If False, a class is a violation if it has less than 3 routines and less than 3 data members. If True, the class is considered a violation if it has less than 3 routines or less than 3 data members.
So a class that contains 2 routines and 4 data members is considered a violation if this option is True, but not if it is False.
 

count_template_routines

count_template_routines : bool = False

Count template routines of class.
 

include_abstract_classes

include_abstract_classes : bool = True

Whether abstract classes should be reported.
 

include_classes_without_definition

include_classes_without_definition : bool = False

Whether classes without definitions should be reported.
 

include_structs

include_structs : bool = False

Whether structs are to be analyzed.
 

include_template_classes

include_template_classes : bool = False

Whether template classes are to be analyzed.
 

min_number_of_members

min_number_of_members : int = 3

Minimal number of data members a class must have to not be considered a classlet.
 

min_number_of_routines

min_number_of_routines : int = 3

Minimal number of routines a class must have to not be considered a classlet.