CQM-PreOrPostnatalCommunication¶
Number of prenatal or postnatal communications
Required inputs: IR, RFG
The metric counts the number of constructors and destructors in which virtual methods are called directly.
Motivation
Virtual routines are used to enable
polymorphism, i.e. sending a message leads to the execution of a routine of the
class whose type the object receiving the message has. Polymorphic calls are also
possible within constructors, but are often very dangerous there, since the
objects receiving the message are not yet fully instantiated (Java) or are of a
type that may not be desired/expected (C++).
Basically, prenatal communication
becomes particularly dangerous when specifications of the subclass SC are used in
the virtual routine if the subclass SC. If this is not the case, prenatal
communication doesn't have to lead to errors. However, since such special
properties cannot be guaranteed in the long term during maintenance,
such constructs should be avoided.
This rule is based on the CQM Quality Indicator: pränatale Kommunikation (p. 274-277).
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
This rule has no predefined messages.
Options¶
This rule shares the following common options: exclude_messages_in_system_headers, excludes, includes, justification_checker, post_processing, provider, severity
This rule shares the following common metric options: base_view_name, excluded_node_types, hierarchy_edge_name, hierarchy_view_name, propagate, report_all_values, report_propagated_values
The following places define options that affect this rule: Analysis-GlobalOptions
display_name¶
display_name : str | None = 'Number of prenatal or postnatal communications'
max_value¶
max_value : int | None = 7
min_value¶
min_value : int | None = 0
rfg_metric_name¶
rfg_metric_name : str = 'Metric.PreOrPostnatalCommunication'