Clang tidy's readability-magic-numbers check is a nightmare.
h_malloc.c:236:28: warning: 4096 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(PAGE_SIZE == 4096, "bitmap handling will need adjustment for other page sizes");
Conversation
Replying to
There are a couple cases where using an existing constant or defining a new one would make sense but it's mostly just noise:
gist.github.com/thestinger/b2f
The bugprone-too-small-loop-variable lint added alongside it in LLVM 8 is also annoying. Doesn't exclude constants it can check.
1
1
I've been messing with the scilab sources lately and checkstyle also complains about magic numbers in the java parts and it's annoying
It's Clang's linter rather than the compiler. I'm explicitly asking it to be opinionated about code style by passing -checks=readability-* but it doesn't make this an acceptable lint pass. The checks in readability should be sensible and avoid spewing out tons of false positives.
1
Show replies


