1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
=encoding utf8
=head1 NAME
clazy - a static source code analyzer for Qt5-based C++.
=head1 SYNOPSIS
clazy [option] [clang++-options]
=head1 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 B<CLAZY_FIXIT>
environment variable description below for more information.
=head1 OPTIONS
=over 4
=item B<--help>
Print help message and exit.
=item B<--version>
Print version information and exit.
=item B<--list>
Print a list of all available checkers, arranged by level.
=item B<--explain>
Print explanations for all checkers.
=item B<--explain> <regexp>
Print explanations for the checkers matching the specified regular expression.
=back
Any of the options above will print the requested information and then exit.
=over 4
=item B<--qtdeveloper>
B<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"
=back
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.
=head1 EXAMPLES
=over 4
=item 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
....
=item Compile your CMake project with clazy default checkers:
% cmake -DCMAKE_CXX_COMPILER=clazy <other_cmake_options>
then make as normal
=item 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
=item Compile your qmake project with clazy default checkers:
% qmake -spec linux-clang QMAKE_CXX=clazy <other_qmake_options>
then make as normal
=back
=head1 IN-CODE DIRECTIVES
clazy supports the following list of in-code directives:
=over 4
=item clazy:skip
Exempt an entire file from all checks.
No clazy tests will run on the file.
=item 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.
=item 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.
=item clazy:exclude-next-line=<name1[,name2,...,nameN]>
Excludes the given clazy checks from the next line.
=back
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.
=head1 ENVIRONMENT
B<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.
B<Examples:>
=over 4
=item 1. Enables the 2 checkers "unneeded-cast" and "virtual-call-ctor" only:
% export CLAZY_CHECKS="unneeded-cast,virtual-call-ctor"
=item 2. Enables all checks from the "level0" check-set, except for "qenums":
% export CLAZY_CHECKS="level0,no-qenums"
=item 3. Enables all checks from the "level0" check-set along with the "detaching-temporary" checker:
% export CLAZY_CHECKS="level0,detaching-temporary"
=back
B<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.
B<Examples:>
=over 4
=item 1. Fix qlatin1string allocations:
% export CLAZY_FIXIT="fix-qlatin1string-allocations"
=item 2. Fix old-style (simple cases) connect statements:
% export CLAZY_FIXIT=fix-old-style-connect
More documentation is provided when running clazy with the B<--explain> command line option.
Also note that only 1 fixit checker can be run at a time.
=back
B<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 B<--explain> command line option.
B<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.
B<CLAZY_CHECKS_AS_ERRORS> - comma-separated list of checks that will be promoted
to compiler errors. Note that this does not enable the checks specified here.
B<CLAZY_IGNORE_DIRS> - A regular expression for paths to exclude from processing.
For example:
% export CLAZY_IGNORE_DIRS=".*my_qt_folder.*"
=head1 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/>.
=head1 SEE ALSO
clang(1)
https://www.kdab.com/use-static-analysis-improve-performance
=head1 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>
=cut
|