0x8000-0000 added inline comments.
================ Comment at: docs/clang-tidy/checks/readability-magic-numbers.rst:11 + + double circleArea = 3.1415926535 * radius * radius; + ---------------- Quuxplusone wrote: > 0x8000-0000 wrote: > > Eugene.Zelenko wrote: > > > JonasToth wrote: > > > > This example is good, but right now the code only checks for integer > > > > literals. Maybe an integer example would be better? > > > Please use .. code-block:: c++. Same for good example. > > @JonasToth I raked my brain but I just can't come up with a short and > > effective example. I haven't given up yet. > A common "magic number" in real code would be something like > ``` > int get_answer() { > if (cond) return x; > return -1; // FILENOTFOUND > } > ``` Thank you. May I use this as an example? The other cases I could find involved either "constants" coming from customer requirements that became variable with age, or examples where the same underlying value was buried inside other pre-calculated values that needed to be kept in sync when the base value changed.... but that does not make for a pithy example. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49114 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits