magic_number
Finds an unexplained number in arithmetic, a comparison or an assignment.
Category pedantic, allow by default.
Off by default; the example is shown with the rule enabled.
#import "Basic";
expires :: (start: int) -> int {
return start + 86400;
}
main :: () {
print("%\n", expires(0));
}warning[magic_number]: magic number `86400` in arithmetic
--> example.jai:4:20
|
4 | return start + 86400;
| ^^^^^
|
= help: name it with a constant (`NAME :: value;`), or add it to `[lint] magic_number_allow`#import "Basic";
SECONDS_PER_DAY :: 86400;
expires :: (start: int) -> int {
return start + SECONDS_PER_DAY;
}
main :: () {
print("%\n", expires(0));
}Off by default. Reports a decimal literal written directly as an operand of + - * / % or a comparison, or as the value of an assignment (x = 37;, x += 37;).