A value is compared with a numeric literal other than 0, 1 or 2 that has no name saying what it is
What it finds
if (len > 1472): a bare number says nothing about what it stands for, and when it is used in several places they have to be found and changed together. A named constant, an enumerator or a macro says both.
Literals in the initializer of a declaration, in enumerators, array lengths, bit-field widths, case labels, macros and the index of an array are left alone, and so are powers of two. Only decimal literals that a value is compared with count, as in conditions and limits.
From the rule's source, magic_number.rs.
int fits(int len){ int limit = 1500; return len > 1472 && len < limit;tx0 reports: 1472 is a number without a name} Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:magic-number" = "warning"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/c:magic-number] reason="..."tx0 explain tx0/c:magic-number shows the same in the terminal. Found a false positive? Report it.