CQM-MemberHiding¶
Data members shall not hide data members in superclasses
Required inputs: RFG
Any data member of a class C is a violation if a data member with the same name exists in a class that directly or indirectly inherits from C.
Motivation
A subclass declares a data member that already exists with the same name in a direct or indirect superclass. If this data member is addressed by its name, it hides the data member of the same name in the superclass (if the data member is visible in the subclass) or merely uses the same name for another variable. Even if the Java and C++ languages see no problem in this and allocate separate memory areas for each case, the naming ambiguity means great risks and additional effort for maintenance.
This rule is based on the CQM Quality Indicator: Attributüberdeckung (p. 170-172).
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 |
|---|---|---|---|
hides_member |
This data member hides a data member in a superclass |
None |
False |
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
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
include_structs¶
include_structs : bool = False
include_template_classes¶
include_template_classes : bool = False