Skip to content

Clazy 1.5 released

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, Febr 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:

New Checks

1. ifndef-define-typo

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/.

2. lowercase-qml-type-name

Warns when QML types registered with qmlRegisterType() or qmlRegisterUncreatableType() don’t start with uppercase. It’s required by the QML engine that they do.

3. qrequiredresult-candidates

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.

New Fixits

To help you automatically rewrite your code, a few new fixits were implemented:

Other

  • Renamed the clazy plugin from ClangLazy.so to ClazyPlugin.so
  • fully-qualified-moc-types now warns for slot/invokable return values too. They need to be fully qualified for QML
  • Many bug fixes, including crashes
FacebookTwitterGoogle+LinkedInEmail

Categories: C++ / KDAB on Qt / News / Qt / Technical / Tooling

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close