No Magic Numbers
Numeric literals other than 0 and 1 used in logic or calculations must be named constants. 'Magic numbers' are numeric literals that appear with no explanation — the reader must guess what 86400 or 3.…
$ aoe install @team/rule-no-magic-numbers Projection
Always in _index.xml · the agent never has to ask for this.
NoMagicNumbers [rule] v1.0.0
Numeric literals other than 0 and 1 used in logic or calculations must be named constants. 'Magic numbers' are numeric literals that appear with no explanation — the reader must guess what 86400 or 3.14159 mean in context.
Loaded when retrieval picks the atom as adjacent / supporting.
NoMagicNumbers [rule] v1.0.0
Numeric literals other than 0 and 1 used in logic or calculations must be named constants. 'Magic numbers' are numeric literals that appear with no explanation — the reader must guess what 86400 or 3.14159 mean in context.
Checks
- Any numeric literal other than 0, 1, -1 used in logic must be extracted to a
constwith a descriptive name. - Array indices beyond 0 must be named if they carry semantic meaning (
FIRST_ITEM = 0,STATUS_CODE = 2). - Allowed exceptions: test data counts, trivial math (halving:
x / 2).
Label
No magic numbers — name all non-trivial numeric literals
Loaded when retrieval picks the atom as a focal / direct hit.
NoMagicNumbers [rule] v1.0.0
Numeric literals other than 0 and 1 used in logic or calculations must be named constants. 'Magic numbers' are numeric literals that appear with no explanation — the reader must guess what 86400 or 3.14159 mean in context.
Checks
- Any numeric literal other than 0, 1, -1 used in logic must be extracted to a
constwith a descriptive name. - Array indices beyond 0 must be named if they carry semantic meaning (
FIRST_ITEM = 0,STATUS_CODE = 2). - Allowed exceptions: test data counts, trivial math (halving:
x / 2).
Label
No magic numbers — name all non-trivial numeric literals
Relations
related: [@team/principle-readability-over-cleverness, @team/anti-pattern-god-class, @team/rule-no-default-export] see-also: [@team/principle-readability-over-cleverness]
Label
No magic numbers — name all non-trivial numeric literals
See Also
- @team/principle-readability-over-cleverness
Source
aoe-engine/examples/coding-style/primes/compiled/@team/rule-no-magic-numbers/atom.yaml