CQM-DeadFields

A private filed of a class is not used

Required inputs: IR

A private field or constant of a class is not used anywhere.
Motivation

A class is used to implement an abstract data type, i.e. to provide services based on data internal to the class. If data is now declared internally, but not required for the provision of services, it is superfluous and only increases the system size.

The considered visibility is limited to private, because only in this case a later (external) use can be ruled out with high probability.

This rule is based on the CQM Quality Indicator: tote Attribute (p. 291-293).

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

unused_field

Unused field

None

False

Options

include_initialized

include_initialized : bool = True

If enabled, initialized fields will be reported as unused, when not used anywhere else.
 

only_private_fields

only_private_fields : bool = True

If enabled, only private fields will be reported.
 

suppress_attribute_maybe_unused

suppress_attribute_maybe_unused : FilterAction = 'suppress'

Filter action to apply to violations for objects marked as [[maybe_unused]] or __attribute__((unused)). If set to "suppress", findings will be reported but marked as suppressed. If set to "exclude", findings will not be reported at all. If set to "normal", no special treatment is applied and the finding is reported as usual.
 

Option Types

These types are used by options listed above:

FilterAction

Used for the return value of add_filter() callbacks.
 

normal

The violation proceeds as usual.

exclude

The violation is excluded: The violation is discarded as if `--exclude` applied to it. The following filters won't get to see the violation, and it will not be imported into the database under any circumstances.

suppress

The violation is suppressed as if `AXIVION DISABLE` applied to it. Whether the violation gets imported into the database is controlled by the Axivion CI configuration.