CQM-ObjectPlaceboMember¶
A static data member is accessed via an object
Required inputs: IR
A static data member is accessed via an object instance instead of the object type. This includes constants.
Motivation
If a static data member (incl. constants) is accessed via an object, this suggests that it is a data member that can only be accessed by means of an object. In particular, this can lead to the object being created only to access the static data members, and thus the instantiation is actually superfluous. The correct way would be to address the data member directly via the class.
This rule is based on the CQM Quality Indicator: Objektplacebo (Attribut) (p. 252-254).
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 |
|---|---|---|---|
object_access |
This static data member is accessed via an object. |
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
This rule has no individual options.