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