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
FacebookTwitterLinkedInEmail

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

2 thoughts on “Clazy 1.5 released”

  1. , Clazy 1.5 released

    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?

Leave a Reply

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