Fix two types of Clazy warnings#5807
Fix two types of Clazy warnings#5807chrchr-github merged 2 commits intocppcheck-opensource:mainfrom gruenich:feature/clazy-fixes
Conversation
This saves memory allocations. Found by Clazy (qstring-arg).
Only include classes that are actually used. Do not pull in all internal dependencies. Found by Clazy (no-module-include).
|
It appears multi-arg only works when the arguments are The GUI now reports error to the terminal (see https://trac.cppcheck.net/ticket/12316): The code in question is in QString bgcolor = QString("background:rgb(%1,%2,%3);")
.arg(mWidgetStyle->widgetBGColor.red(),
mWidgetStyle->widgetBGColor.green(),
mWidgetStyle->widgetBGColor.blue());All of the arguments are This is with Qt5 though. I have not checked if Qt6 has additional overloads. |
|
Qt6 has a varargs overload but that also only works with strings. From https://doc.qt.io/qt-6/qstring.html#arg-14: |
|
It sounds like the clazy check should detect exactly this kind of misuse that we have now: |
I thought about that but it doesn't offer that much of interest and has several false positives. My IDE supports Clazy but it seems I am not able to specify the extra option. |
|
@gruenich Can you revert the |
I'd prefer a partial revert to get it running on Ubuntu 20.04, too. Focal provides an older version of Qt 5.12 which might lack some features. |
|
Reverted in #5902. |
Chained QString::arg, replace inclusion of QtCore