My specific problem is that cppcoreguidelines-avoid-magic-numbers
is flagging calls to setters. For example:
auto person = Person();
person.set_height(6); // <--- Flagged as "magic number"
This really isn't a magic number, as the context for what the number represents is made explicit by the setter call itself (it's a Person
's height in this case). So I'd like to be able to ignore the cppcoreguidelines-avoid-magic-numbers
for all calls to set_height
.
What I'd like to be able to do in general is ignore <list-of-warnings>
on all invocations of <some-function>
, and only ignore on those function invocations (e.g. disabling globally is not desired).
As a workaround, I could write an emacs save hook to go insert // NOLINT(cppcoreguidlines-avoid-magic-numbers)
after every line that matches these setters. I'd really rather not do that.
Is this possible to do in an easier way? Are there other workarounds that handle this issue?