1CLAZY(1)                             KDAB                             CLAZY(1)
2
3
4

NAME

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

SYNOPSIS

9       clazy [option] [clang++-options]
10

DESCRIPTION

12       clazy scans C++/Qt source code looking for issues related to good
13       coding practice with of Qt5.  In typical use, during code compilation
14       with clazy you will see any such warnings printed to the output
15       normally as you would find any compiler warnings.
16
17       clazy has the ability to "fix" the offending code in some cases.  See
18       the CLAZY_FIXIT environment variable description below for more
19       information.
20

OPTIONS

22       --help
23           Print help message and exit.
24
25       --version
26           Print version information and exit.
27
28       --list
29           Print a list of all available checkers, arranged by level.
30
31       --explain
32           Print explanations for all checkers.
33
34       --explain <regexp>
35           Print explanations for the checkers matching the specified regular
36           expression.
37
38       Any of the options above will print the requested information and then
39       exit.
40
41       --qt4compat
42           This option runs clazy in Qt4 compatibility mode.  Use this when
43           your source code can build with Qt4 and Qt5 in order to easily
44           suppress issues that cannot be fixed due to the requirement of the
45           Qt4 API.
46
47           This is a convenience option which is identical to directly
48           passing:
49             "-Xclang -plugin-arg-clazy -Xclang qt4-compat"
50
51       --qtdeveloper
52           For Qt developers only.  This option is special for running clazy
53           on Qt itself.  Will result in fewer false positives being reported
54           in Qt code.
55
56           This is a convenience option which is identical to directly
57           passing:
58             "-Xclang -plugin-arg-clazy -Xclang qt-developer"
59
60       All other options are passed directly to clang++ and handled from
61       there.
62
63       See the clang manual for a list of the very large set of options
64       available, but in normal operation you "compile" your code with clazy
65       just as you would with clang.
66

EXAMPLES

68       Print a list of all available checkers, arranged by check level:
69            % clazy --list
70
71            List of available clazy checkers:
72
73            Checks from level0. Very stable checks, 100% safe, no false-positives:
74               connect-non-signal
75               container-anti-pattern
76               lambda-in-connect
77               mutable-container-key
78               qdatetime-utc
79               qenums
80               qfileinfo-exists
81             ....
82
83       Compile your CMake project with clazy default checkers:
84            % cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
85            then make as normal
86
87       Compile your CMake project with level2 checks only (non-Windows):
88            % export CLAZY_CHECKS="level2"
89            % cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
90            then make as normal
91
92       Compile your qmake project with clazy default checkers:
93            % qmake -spec linux-clang QMAKE_CXX=clazy <other_qmake_options>
94            then make as normal
95

IN-CODE DIRECTIVES

97       clazy supports the following list of in-code directives:
98
99       clazy:skip
100            Exempt an entire file from all checks.
101            No clazy tests will run on the file.
102
103       clazy:excludeall=<name1[,name2,...,nameN]>
104            Exempt the entire file from the specified checks.
105            The clazy checks name1, etc will not be run on this file.
106
107       clazy:exclude=<name1[,name2,...,nameN]>
108            Exclude individual lines from specific checks.
109            The clazy checks tests name1, etc. will not be run on the line where
110            this directive is found.
111
112       Don't include the 'clazy-' prefix.  For example, to disable the
113       "qstring-allocations" check, you would write:
114
115           // clazy:exclude=qstring-allocations
116
117       and not
118
119           // clazy:exclude=clazy-qstring-allocations
120
121       Also note that these directives must be C++ style comments; C style
122       comments are ignored.
123

ENVIRONMENT

125       CLAZY_CHECKS - a comma-separated list of checkers or check-sets to run.
126       By default, all checkers from the "level0" and "level1" check-sets will
127       run.
128
129       Examples:
130
131       1. Enables the 2 checkers "unneeded-cast" and "virtual-call-ctor" only:
132           % export CLAZY_CHECKS="unneeded-cast,virtual-call-ctor"
133
134       2. Enables all checks from the "level0" check-set, except for "qenums":
135           % export CLAZY_CHECKS="level0,no-qenums"
136
137       3. Enables all checks from the "level0" check-set along with the
138       "detaching-temporary" checker:
139           % export CLAZY_CHECKS="level0,detaching-temporary"
140
141       CLAZY_FIXIT - some checkers are able to automatically re-write your
142       source code whenever it encounters code it can "fix".  Enable this
143       "fixit" feature by setting this variable to the name of the checker
144       with a "fixit" capability.
145
146       Examples:
147
148       1. Fix qlatin1string allocations:
149           % export CLAZY_FIXIT="fix-qlatin1string-allocations"
150
151       2. Fix old-style (simple cases) connect statements:
152           % export CLAZY_FIXIT=fix-old-style-connect
153
154           More documentation is provided when running clazy with the
155           --explain command line option.
156
157           Also note that only 1 fixit checker can be run at a time.
158
159       CLAZY_EXTRA_OPTIONS - some checkers can adapt their behavior depending
160       on the value of this environment variable.  More documentation is
161       provided when running clazy with the --explain command line option.
162
163       CLAZY_NO_WERROR - if this is variable is set, clazy will not treat
164       warnings as errors, even if the -Werror compiler option is specified.
165       This is useful if you want to use -Werror only for the regular
166       gcc/clang warnings but not for clazy warnings.
167
169       Copyright (C) 2015-2017 Klaralvdalens Datakonsult AB, a KDAB Group
170       company, <info@kdab.com>
171
172       This library is free software; you can redistribute it and/or modify it
173       under the terms of the GNU Lesser General Public License as published
174       by the Free Software Foundation; either version 2.1 of the License, or
175       (at your option) any later version.
176
177       This library is distributed in the hope that it will be useful, but
178       WITHOUT ANY WARRANTY; without even the implied warranty of
179       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
180       Lesser General Public License for more details.
181
182       You should have received a copy of the GNU Lesser General Public
183       License along with this library.  If not, see
184       <http://www.gnu.org/licenses/>.
185

SEE ALSO

187        clang(1)
188        https://www.kdab.com/use-static-analysis-improve-performance
189

AUTHORS

191        Sergio Martins <sergio.martins@kdab.com>
192        Laurent Montel <laurent.montel@kdab.com>
193        Allen Winter <allen.winter@kdab.com>
194        Albert Astals Cid <aacid@kde.org>
195        Aurelien Gateau <agateau@kde.org>
196        Kevin Funk <kevin.funk@kdab.com>
197        Hannah von Reth <hannah.vonreth@kdab.com>
198        Volker Krause <volker.krause@kdab.com>
199        Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
200        Mathias Hasselmann <mathias.hasselmann@kdab.com>
201
202
203
2041.6.0                             2019-10-30                          CLAZY(1)
Impressum