CQM-ConstantsRain¶
Global constants should have unique names
Required inputs: IR
There must not be more than one global constant with the same name in the system.
Motivation
Global constants are constants declared for use in many different places in the system. Since a large number of constants are usually necessary in large systems, a dedicated constant concept is required.
In any case, it should be avoided that globally visible constants occur several times by name, since otherwise different contents can be addressed with the same name. At any rate, with a constants rain there is the danger that a retrieval, adjustment and change of a special constant is possible only with large time expenditure. If these redundant constants have different values, the functionality is probably also endangered. A change of a constant value must then be repeated possibly at several other places. If a place is forgotten, the behavior of the program gets possibly out of control.
This rule is based on the CQM Quality Indicator: Konstantenregen (p. 234-236).
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 |
|---|---|---|---|
reused_global_variable_name |
Name of constant with static storage duration reused. |
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
allow_static_no_linkage¶
allow_static_no_linkage : bool = False
include_local_variables¶
include_local_variables : bool = True
use_unqualified_names¶
use_unqualified_names : bool = True
ns1::Type is considered equal to
ns2::Type.
var_filter¶
var_filter : typing.Callable[[Variable], bool] | None = <function bauhaus.rules.cqm.rules.constants_rain._filter_const(node: Variable) -> bool>