CQM-PotentialPrivacyMember

Data members that could have more private scopes

Required inputs: IR, RFG

The metric considers data members (not constants) whose visibility can be reduced within a class. That is, a data member with public visibility can have protected visibility because it is not accessed outside the inheritance hierarchy. And for data members with protected visibility, they can be private if they are not accessed by any other class in the inheritance hierarchy. Any data member to which this applies is a violation for this rule.

Motivation

The visibility concept in object-oriented languages allows the explication of priorities in understanding and modifying systems. A maximally visible programming artifact is thus particularly important for understanding the functionality offered externally; in contrast, an artifact declared as private is less important for primarily understanding the interaction of system parts.
The prioritization made explicit by the visibility concept is analyzed in this data member quality indicator. If data members have too high visibility, i.e., based on their actual use their visibility could be reduced to protected or private, then there is incorrect prioritization. With a restriction of visibility, the data members would receive a lower priority for understanding and modification. It would also protect them from unwanted access, which in turn improves the stability of the program. Reducing visibility does not result in a loss of information or functionality.

This rule is based on the CQM Quality Indicator: potenzielle Privatsphäre (Attribut) (p. 267-270).

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

protected_could_private

This data member is protected but could be private.

None

False

public_could_private

This data member is public but could be private.

None

False

public_could_protected

This data member is public but could be protected.

None

False

Options

include_template_classes

include_template_classes : bool = True

Whether template classes are to be analyzed.