CQM-SignatureLikeClasses¶
Two unrelated classes should not have most of their routines in common
Required inputs: IR
Two classes that do not inherit from each other or have a common superclass are considered a violation if more than 10 routines or more than 50 percent of the routines from both have the same signatures.
Motivation
Inheritance is an important concept for making similarities between different classes explicit. Once this is done, it creates higher-level class clusters, each of which can be understood, maintained, and tested cohesively. An important aspect of similarity is identical signatures of routines.
If classes exist that have no direct or indirect relation to inheritance, but nevertheless have many similarities, the advantages of inheritance are not used for this class. Rather, this results in risks of repeated maintenance, repeated testing, and duplication with subsequent variant construction. In particular, the lack of explicitly made class clusters has a significant negative impact on understanding and modifying large systems.
This rule is based on the CQM Quality Indicator: signaturähnliche Klassen (p. 281-284).
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 |
|---|---|---|---|
signature_like_classes |
These classes share {num} routines with the same signatures. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
max_number_routines¶
max_number_routines : int = 10
max_percentage_routines¶
max_percentage_routines : float = 50.0