Bug 353767 - Support for a supression file
Summary: Support for a supression file
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-10 17:42 UTC by Sergio Martins
Modified: 2016-04-24 17:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Martins 2015-10-10 17:42:42 UTC
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
Comment 1 Richard 2016-04-08 09:00:23 UTC
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.
Comment 2 Sergio Martins 2016-04-14 15:22:26 UTC
(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
Comment 3 Richard 2016-04-18 07:28:33 UTC

(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
Comment 4 Sergio Martins 2016-04-20 21:17:16 UTC
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
Comment 5 Sergio Martins 2016-04-24 12:44:19 UTC
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
Comment 6 Sergio Martins 2016-04-24 17:06:59 UTC
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