A variable at namespace scope is not const, so any code in the program can change it
What it finds
Mutable globals couple every function that touches them, make the order of initialization across files matter and need locks once threads share them. A constant, a function-local static or an object passed where it is needed keeps the state contained. Declarations with extern and no initializer, which refer to a variable defined elsewhere, are left alone.
From the rule's source, mutable_global_variable.rs.
Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/cpp:mutable-global-variable" = "note"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/cpp:mutable-global-variable] reason="..."tx0 explain tx0/cpp:mutable-global-variable shows the same in the terminal. Found a false positive? Report it.