Sometimes there are false-positives, would be cool if clazy supported a suppresion file, so it wouldn't warn on those cases. Design ideas welcome. Reproducible: Always
It would be possible to work with clazy warnings like ordinary compiler warnings? E.g. have them disabled locally with #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wclazy-somecheck" //some offending code #pragma clang diagnostic pop Also this would allow to treat some of the clazy warnings as errors and some still as warnings.
(In reply to Richard from comment #1) > It would be possible to work with clazy warnings like ordinary compiler > warnings? > E.g. have them disabled locally with > > #pragma clang diagnostic push > #pragma clang diagnostic ignored "-Wclazy-somecheck" > //some offending code > #pragma clang diagnostic pop > > Also this would allow to treat some of the clazy warnings as errors and some > still as warnings. Good idea but I couldn't find a way to implement this. There's no way for a plugin to register warnings that #pragma would understand
(In reply to Sergio Martins from comment #2) > (In reply to Richard from comment #1) > > It would be possible to work with clazy warnings like ordinary compiler > > warnings? > > E.g. have them disabled locally with > > > > #pragma clang diagnostic push > > #pragma clang diagnostic ignored "-Wclazy-somecheck" > > //some offending code > > #pragma clang diagnostic pop > > > > Also this would allow to treat some of the clazy warnings as errors and some > > still as warnings. > > Good idea but I couldn't find a way to implement this. There's no way for a > plugin to register warnings that #pragma would understand It could be done by registering an own PragmaHandler [1]. But at the cost of having either a "Unknown pragma" warning on not-clazy runs, or using a macro which expands to the pragma or nothing on ordinary compiles. Or of course disable that particular warning all together. It would nevertheless be a decision which has to be made by the user of the tool and purely opt-in. [1] http://clang.llvm.org/doxygen/classclang_1_1PragmaHandler.html
Pragmas seem too crude, they act on the whole file unless you do a lot of push/pop. I'm thinking about a special comment which if present will tell clazy to shut up, just like we have for krazy
Git commit 4aa04494e33dcf5e853d76bacec2afb58a7e0100 by Sergio Martins. Committed on 24/04/2016 at 12:40. Pushed by smartins into branch 'suppressions'. Introduce krazy like suppressions // clazy:skip Ignore the whole file // clazy:excludeall=check1,check2 Ignore the whole file for these checks // clazy:exclude=qstring-allocations Ignore these checks in specific line numbers M +3 -0 CMakeLists.txt M +13 -0 README A +135 -0 SuppressionManager.cpp [License: LGPL (v2+)] A +65 -0 SuppressionManager.h [License: LGPL (v2+)] M +5 -1 checkbase.cpp M +3 -1 checkbase.h M +5 -0 checkmanager.cpp M +4 -0 checkmanager.h M +8 -0 tests/clazy/config.json A +23 -0 tests/clazy/suppressions.cpp [License: UNKNOWN] * A +1 -0 tests/clazy/suppressions.cpp.expected A +10 -0 tests/clazy/suppressionsWholeFile.cpp [License: UNKNOWN] * A +0 -0 tests/clazy/suppressionsWholeFile.cpp.expected The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. http://commits.kde.org/clazy/4aa04494e33dcf5e853d76bacec2afb58a7e0100
Git commit c252e400f1e123eabb9c1511131f50d86154c997 by Sergio Martins. Committed on 24/04/2016 at 17:03. Pushed by smartins into branch 'master'. Introduce krazy like suppressions // clazy:skip Ignore the whole file // clazy:excludeall=check1,check2 Ignore the whole file for these checks // clazy:exclude=qstring-allocations Ignore these checks in specific line numbers M +3 -0 CMakeLists.txt M +13 -0 README A +135 -0 SuppressionManager.cpp [License: LGPL (v2+)] A +65 -0 SuppressionManager.h [License: LGPL (v2+)] M +5 -1 checkbase.cpp M +3 -1 checkbase.h M +5 -0 checkmanager.cpp M +4 -0 checkmanager.h M +8 -0 tests/clazy/config.json A +23 -0 tests/clazy/suppressions.cpp [License: UNKNOWN] * A +1 -0 tests/clazy/suppressions.cpp.expected A +10 -0 tests/clazy/suppressionsWholeFile.cpp [License: UNKNOWN] * A +0 -0 tests/clazy/suppressionsWholeFile.cpp.expected The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. http://commits.kde.org/clazy/c252e400f1e123eabb9c1511131f50d86154c997