CLAZY(1)

NAME
clazy - a static source code analyzer for Qt5-based C++.

SYNOPSIS
clazy [option] [clang++-options]

DESCRIPTION
clazy scans C++/Qt source code looking for issues related to good coding practice with of Qt5. In typical use, during code compilation with clazy you will see any such warnings printed to the output normally as you would find any compiler warnings.

clazy has the ability to "fix" the offending code in some cases. See the CLAZY_FIXIT environment variable description below for more information.

OPTIONS

--help
    Print help message and exit.

--version
    Print version information and exit.

--list
    Print a list of all available checkers, arranged by level.

--explain
    Print explanations for all checkers.

--explain <regexp>
    Print explanations for the checkers matching the specified regular expression.

Any of the options above will print the requested information and then exit.

--qt4compat
    This option runs clazy in Qt4 compatibility mode. Use this when your source code can build with Qt4 and Qt5 in order to easily suppress issues that cannot be fixed due to the requirement of the Qt4 API.

    This is a convenience option which is identical to directly passing:
      "-Xclang -plugin-arg-clazy -Xclang qt4-compat"

--qtdeveloper
    For Qt developers only. This option is special for running clazy on Qt itself. Will result in fewer false positives being reported in Qt code.

    This is a convenience option which is identical to directly passing:
      "-Xclang -plugin-arg-clazy -Xclang qt-developer"

All other options are passed directly to clang++ and handled from there.

See the clang manual for a list of the very large set of options available, but in normal operation you "compile" your code with clazy just as you would with clang.

EXAMPLES

Print a list of all available checkers, arranged by check level:
     % clazy --list

     List of available clazy checkers:

     Checks from level0. Very stable checks, 100% safe, no false-positives:
        connect-non-signal
        container-anti-pattern
        lambda-in-connect
        mutable-container-key
        qdatetime-utc
        qenums
        qfileinfo-exists
      ....

Compile your CMake project with clazy default checkers:
     % cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
     then make as normal

Compile your CMake project with level2 checks only (non-Windows):
     % export CLAZY_CHECKS="level2"
     % cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
     then make as normal

Compile your qmake project with clazy default checkers:
     % qmake -spec linux-clang QMAKE_CXX=clazy <other_qmake_options>
     then make as normal

IN-CODE DIRECTIVES
clazy supports the following list of in-code directives:

clazy:skip
     Exempt an entire file from all checks.
     No clazy tests will run on the file.

clazy:excludeall=<name1[,name2,...,nameN]>
     Exempt the entire file from the specified checks.
     The clazy checks name1, etc will not be run on this file.

clazy:exclude=<name1[,name2,...,nameN]>
     Exclude individual lines from specific checks.
     The clazy checks tests name1, etc. will not be run on the line where
     this directive is found.

Don't include the 'clazy-' prefix. For example, to disable the "qstring-allocations" check, you would write:

    // clazy:exclude=qstring-allocations

and not

    // clazy:exclude=clazy-qstring-allocations

Also note that these directives must be C++ style comments; C style comments are ignored.

ENVIRONMENT
CLAZY_CHECKS - a comma-separated list of checkers or check-sets to run. By default, all checkers from the "level0" and "level1" check-sets will run.

Examples:

1. Enables the 2 checkers "unneeded-cast" and "virtual-call-ctor" only:
    % export CLAZY_CHECKS="unneeded-cast,virtual-call-ctor"

2. Enables all checks from the "level0" check-set, except for "qenums":
    % export CLAZY_CHECKS="level0,no-qenums"

3. Enables all checks from the "level0" check-set along with the "detaching-temporary" checker:
    % export CLAZY_CHECKS="level0,detaching-temporary"

CLAZY_FIXIT - some checkers are able to automatically re-write your source code whenever it encounters code it can "fix". Enable this "fixit" feature by setting this variable to the name of the checker with a "fixit" capability.

Examples:

1. Fix qlatin1string allocations:
    % export CLAZY_FIXIT="fix-qlatin1string-allocations"

2. Fix old-style (simple cases) connect statements:
    % export CLAZY_FIXIT=fix-old-style-connect

    More documentation is provided when running clazy with the --explain command line option.

    Also note that only 1 fixit checker can be run at a time.

CLAZY_EXTRA_OPTIONS - some checkers can adapt their behavior depending on the value of this environment variable. More documentation is provided when running clazy with the --explain command line option.

CLAZY_NO_WERROR - if this is variable is set, clazy will not treat warnings as errors, even if the -Werror compiler option is specified. This is useful if you want to use -Werror only for the regular gcc/clang warnings but not for clazy warnings.

COPYRIGHT AND LICENSE
Copyright (C) 2015-2017 Klaralvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>.

SEE ALSO
 clang(1)
 https://www.kdab.com/use-static-analysis-improve-performance

AUTHORS
 Sergio Martins <sergio.martins@kdab.com>
 Laurent Montel <laurent.montel@kdab.com>
 Allen Winter <allen.winter@kdab.com>
 Albert Astals Cid <aacid@kde.org>
 Aurélien Gâteau <agateau@kde.org>
 Kevin Funk <kevin.funk@kdab.com>
 Hannah von Reth <hannah.vonreth@kdab.com>
 Volker Krause <volker.krause@kdab.com>
 Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
 Mathias Hasselmann <mathias.hasselmann@kdab.com>