cppclean icon indicating copy to clipboard operation
cppclean copied to clipboard

Support for ignoring warning

Open drodil opened this issue 7 years ago • 2 comments

There should be possibility to ignore warnings with some comment in code for example:

// NOCLEAN
#include "not_needed_header.h"

This would help with false-positives until the other issues are fixed.

drodil avatar Feb 23 '18 06:02 drodil

This wonderful packages gets a lot of use from the c++ community and it's been quite some time since this has been requested. There have even been a few SO posts asking for this feature:

  • https://stackoverflow.com/questions/35517785/how-to-exclude-files-for-cppclean-run
  • https://stackoverflow.com/questions/60957481/is-there-a-way-to-suppress-cppclean-issues

I will put in a PR for this feature today. OP suggested it can be used to silence false positives. Most of the issues at the time are now resolved. It is nonetheless a helpful feature for development and for some design conventions that appear to linting tools as being redundant. For example some developers include a *.tpp file inside a header to separate a template definition from its implementation.

I suggest we use similar syntax to other tools such as eslint:

// cppclean-disable

The minimum requirements for this feature are:

// 1. Disable for a whole file
// cppclean-disable

// 2. Disable for a single line
// cppclean-disable-next-line

Additions that will be nice in the future are:

// 3. Support block style comments
/* cppclean-disable-next-line */

// 4. Re-enable after a block
// cppclean-disable
// cppclean-enable

// 5. Disable selected rules only
// cppclean-disable already-included

// 6. Re-enable a subset of selected rules
// cppclean-disable already-included, static-data
// cppclean-enable already-included

JoelLefkowitz avatar Apr 30 '22 10:04 JoelLefkowitz

PR in #162

JoelLefkowitz avatar Apr 30 '22 13:04 JoelLefkowitz