Summary: | clazy-fully-qualified-moc-types not detecting missing namespace | ||
---|---|---|---|
Product: | [Developer tools] clazy | Reporter: | Christian Gagneraud <chgans> |
Component: | general | Assignee: | Unassigned bugs mailing-list <unassigned-bugs> |
Status: | REOPENED --- | ||
Severity: | normal | CC: | dushistov, smartins, szehowe.koh |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/sdk/clazy/commit/b183b3312edd1781788cc598d5a89f344d7c8d7f | Version Fixed In: | |
Sentry Crash Report: |
Description
Christian Gagneraud
2020-07-02 04:24:42 UTC
I get the same problem. I made some experiments, and looks like clazy should be run against output of moc, not against header by it self: ``` // boo.h #pragma once #include <QObject> namespace MyNameSpace { struct MyGadget { Q_GADGET }; class MyObject : public QObject { Q_OBJECT Q_PROPERTY(MyGadget myprop READ myprop CONSTANT); // Wrong, needs namespace public: MyGadget myprop() const; }; } ``` clazy-standalone --extra-arg="-I/usr/lib/clang/11.1.0/include" --checks=level0,level1,level2 -p ./build/compile_commands.json boo.h reports nothing, but ``` $ clazy-standalone --extra-arg="-I/usr/lib/clang/11.1.0/include" --checks=level0,level1,level2 -p ./build/compile_commands.json build/moc_boo.cpp In file included from moc_boo.cpp:10: build/../boo.h:11:5: warning: Q_PROPERTY of type MyGadget should use full qualification (MyNameSpace::MyGadget) [-Wclazy-fully-qualified-moc-types] class MyObject : public QObject ^ 1 warning generated. ``` Git commit b183b3312edd1781788cc598d5a89f344d7c8d7f by Sergio Martins. Committed on 15/05/2021 at 09:48. Pushed by smartins into branch 'master'. fully-qualified-moc-types: Explain why Q_PROPERTY warns on moc output only Q_PROPERTY is a macro that doesn't expand to anything. It won't appear in the AST. The properties only appear in the moc output. It will warn that your Q_PROPERTY needs to be fully qualified when you do a full build with clazy as the compiler, but probably not in QtCreator's inline warnings. Working at the Lexer level without a code model would not only be hardwork but would be flaky with many corner cases and false-positives. M +3 -0 docs/checks/README-fully-qualified-moc-types.md https://invent.kde.org/sdk/clazy/commit/b183b3312edd1781788cc598d5a89f344d7c8d7f The patched documentation addresses the missing warning in Q_PROPERTY(). What about the test case in the original post? namespace N { class C: QObject { enum E {}; signals: void function(C::E value) {} // Wrong, needs namespace }; } See also https://bugreports.qt.io/browse/QTCREATORBUG-28120 |