Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Clazy 1.5 is now available. This is a small release, mainly focused on bug fixing.
Clazy is a clang compiler plugin which emits warnings related to Qt best practices. We'll be showing Clazy at Embedded World, Nuremberg, Feb 26-28, where we are a main Qt partner.
You can read more about it in our previous blog posts:
As usual, MSVC and AppImage binaries are available at http://downloads.kdab.com/clazy.
The interesting part of the ChangeLog is as follows:
Tries to find cases where a #define
following an #ifndef
defines a different but similar name.
Example:
#ifndef GL_FRAMEBUFFER_SRG // Oops, typo.
# define GL_FRAMEBUFFER_SRGB 0x8DB9
#endif
It uses a Levenshtein Distance algorithm so it will only warn if the names are similar.
This check is disabled by default as it can report many false-positives. Nevertheless you should give it a go, it even found a bug in Qt: https://codereview.qt-project.org/#/c/242090/.
Warns when QML types registered with qmlRegisterType()
or qmlRegisterUncreatableType()
don't start with uppercase. It's required by the QML engine that they do.
Suggests methods that could be marked as [[nodiscard]] (via Q_REQUIRED_RESULT
).
Functions annotated with this attribute will trigger a compiler warning if their value is unused.
Clazy's criteria for making such suggestion is: const methods, returning the same type as their class and ending with 'ed'
For example, the signature for QRect::intersected()
should be written as:
Q_REQUIRED_RESULT QRect intersected(const QRect &other) const
so that user code will get a warning when discarding the result.
To help you automatically rewrite your code, a few new fixits were implemented:
qAsConst()
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Upgrade your applications from Qt 5 to Qt 6 with KDAB’s migration services. Get a free migration assessment and join a hands-on workshop to prepare your team for a successful transition!
Learn more
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more
2 Comments
9 - Feb - 2020
chgans
Hi,
There was no announcement for 1.6 but there's a tag in the git repo and the master's Readme says 'Clazy 1.7' Was Clazy-1.6 officially released?
10 - Feb - 2020
sergio
yes, the announcement was made here: https://mail.kde.org/pipermail/kde-announce-apps/2019-October/005549.html