Bug 400452 - disabling checks doesn't work
Summary: disabling checks doesn't work
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-29 18:10 UTC by Matthew Woehlke
Modified: 2018-11-11 17:05 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 Matthew Woehlke 2018-10-29 18:10:14 UTC
SUMMARY
The documentation ("Selecting which checks to enable") gives this example to exclude a check:

  export CLAZY_CHECKS="level0,no-qenums" # Enables all checks from level0, except for qenums

However, this does not work, at least for the range-loop check.

STEPS TO REPRODUCE
1. Write some code that makes the range-loop check unhappy.
2. Run clazy: CLAZY_CHECKS="level0,no-range-loop" clazy -p=build/dir sources/*.cxx

OBSERVED RESULT
Clazy issues range-loop reports.

EXPECTED RESULT
Clazy should not issue any range-loop reports.

SOFTWARE VERSIONS
Clazy: 534aa592b4a074206eb4e89dd096363dc8040b5f
Clang: clang-6.0.1-2.fc28.x86_64

ADDITIONAL INFORMATION
Omitting a level (CLAZY_CHECKS="no-range-loop") suppresses the check as expected. The problem seems to be that specifying levels sometimes (maybe only for level0 checks?) takes precedence over suppressing individual checks, which is both annoying and is contrary to the documentation. However, for other checks (e.g. old-style-connect), suppression is working as expected.
Comment 1 Matthew Woehlke 2018-10-29 18:15:47 UTC
Wow... fiddling with this some more (and also looking at the clazy sources), it seems that clazy is doing the right thing *if* run on a single source file. Actually, what may be happening is that the list of suppressions is not applied past the first source file. (This works for checks that wouldn't be enabled by default because enabling a level is first expanded to all checks for that level, then any suppressions are removed, so the suppressed check is never propagated.)
Comment 2 Matthew Woehlke 2018-10-30 16:41:34 UTC
FYI: possible fix at https://phabricator.kde.org/D16517.
Comment 3 Sergio Martins 2018-11-11 17:05:07 UTC
done, thanks

commit fbc245d3ddedf648b21b94194a6227c0492f1fa2 (HEAD -> 1.4, origin/1.4)
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date:   Sun Nov 11 17:02:30 2018 +0000

    Fix disabling checks
    
    Modify CheckManager::requestedChecksThroughEnv to also cache the list of user disabled checks.
    This is required to be able to correctly disable checks that would be enabled by default.
    
    REVIEW: D16517