Bug 474657 - clazy is showing no-module-include issues as "errors" not "warnings"
Summary: clazy is showing no-module-include issues as "errors" not "warnings"
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Jazeix Johnny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-18 16:02 UTC by Allen Winter
Modified: 2023-09-20 19:13 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Allen Winter 2023-09-18 16:02:49 UTC
STEPS TO REPRODUCE
1.  run clazy on a Qt5 project

OBSERVED RESULT
seen in the output:

In file included from /home/build/Qt-com/5.15.9/gcc_64/include/QtPrintSupport/QtPrintSupport:3:
/home/build/Qt-com/5.15.9/gcc_64/include/QtPrintSupport/QtPrintSupportDepends:3:10: error: Module QtCore should not be included directly [-Wclazy-no-module-include]
#include <QtCore/QtCore>
         ^
/home/build/Qt-com/5.15.9/gcc_64/include/QtPrintSupport/QtPrintSupportDepends:4:10: error: Module QtGui should not be included directly [-Wclazy-no-module-include]
#include <QtGui/QtGui>
         ^
/home/build/Qt-com/5.15.9/gcc_64/include/QtPrintSupport/QtPrintSupportDepends:5:10: error: Module QtWidgets should not be included directly [-Wclazy-no-module-include]
#include <QtWidgets/QtWidgets>
         ^
3 errors generated.

EXPECTED RESULT
how come those are "errors" and not "warnings"?
Comment 1 Jazeix Johnny 2023-09-20 06:08:19 UTC
I can't reproduce this one, they are warnings in the test and I've check on another project and they are warnings too.
By any chance, are you sure there is no settings to force warnings as errors in your project?
Comment 2 Allen Winter 2023-09-20 16:20:20 UTC
good idea.  I'll set CLAZY_NO_WERROR to make sure
Comment 3 Allen Winter 2023-09-20 16:30:04 UTC
however, I don't think issues from inside Qt5 itself should be reported at all (unless the --qtdeveloper option is set
Comment 4 Jazeix Johnny 2023-09-20 18:38:03 UTC
I think the issue here is that you include directly the module QtPrintSupport which, as other Qt modules, include all the modules and not the relevant classes (https://codebrowser.dev/qt5/qtbase/include/QtPrintSupport/QtPrintSupport.html).

Wouldn't it be better to add it in the list of warnings to tell the user to directly use the relevant classes of QtPrintSupport (https://invent.kde.org/sdk/clazy/-/commit/b205b52c0efbee044fd9377e077cb73e8772c8f8#dd685b92c5cf09d7fb134070ca5b0febc6e8b8e3_0_40)?
Comment 5 Jazeix Johnny 2023-09-20 18:41:46 UTC
(In reply to Jazeix Johnny from comment #4)
> I think the issue here is that you include directly the module
> QtPrintSupport which, as other Qt modules, include all the modules and not
> the relevant classes
> (https://codebrowser.dev/qt5/qtbase/include/QtPrintSupport/QtPrintSupport.
> html).
> 
> Wouldn't it be better to add it in the list of warnings to tell the user to
> directly use the relevant classes of QtPrintSupport
> (https://invent.kde.org/sdk/clazy/-/commit/
> b205b52c0efbee044fd9377e077cb73e8772c8f8#dd685b92c5cf09d7fb134070ca5b0febc6e8
> b8e3_0_40)?

I've just checked and we already ignore when it's included from a Qt module, the issue is that I missed the QtPrintSupport module. I did it manually, I'm not sure if there is an automatic way to list of the Qt modules to ensure I didn't miss more
Comment 6 Bug Janitor Service 2023-09-20 18:51:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/clazy/-/merge_requests/88
Comment 7 Jazeix Johnny 2023-09-20 19:13:26 UTC
Git commit 2965bc3fca609f4a401709263f0d0fdcff8bf763 by Johnny Jazeix.
Committed on 20/09/2023 at 20:50.
Pushed by winterz into branch 'master'.

add missing PrintSupport module for no-module-include check

M  +1    -1    src/checks/level0/no-module-include.cpp
M  +2    -0    tests/no-module-include/main.cpp
M  +2    -0    tests/no-module-include/main.cpp.expected

https://invent.kde.org/sdk/clazy/-/commit/2965bc3fca609f4a401709263f0d0fdcff8bf763