Bug 400452

Summary: disabling checks doesn't work
Product: [Developer tools] clazy Reporter: Matthew Woehlke <mwoehlke.floss>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: normal CC: smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

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