Bug 399544 - clazy-empty-qstringliteral for uic generated files
Summary: clazy-empty-qstringliteral for uic generated files
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: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-09 09:15 UTC by Evgeniy A. Dushistov
Modified: 2018-12-13 11:09 UTC (History)
1 user (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 Evgeniy A. Dushistov 2018-10-09 09:15:55 UTC
SUMMARY

clazy-empty-qstringliteral is great, but it produces too many warnings for uic generated files.

STEPS TO REPRODUCE
1. Create ".ui" file
2. Change stylesheet to something, and then clear it.
3. You will get in generated by uic c++ code, something like:

        ActionConfirmContextMenu->setStyleSheet(QStringLiteral(""));

OBSERVED RESULT


EXPECTED RESULT

It would be great if clazy automatically disable `clazy-empty-qstringliteral` 
for headers file that starts with "ui_" and ends with ".h"

SOFTWARE VERSIONS
(available in About System)
Qt Version: 5.11.2

ADDITIONAL INFORMATION
Comment 1 Sergio Martins 2018-10-09 09:38:41 UTC
Does it happen only for stylesheets ?
Comment 2 Sergio Martins 2018-10-09 09:48:49 UTC
Probably any property. Deserves to be fixed in Qt first though.
Comment 3 Sergio Martins 2018-10-09 10:41:47 UTC
Git commit 6e5fee3730ad2e443d9ec93eb88f06ee7f8b33e2 by Sergio Martins.
Committed on 09/10/2018 at 10:37.
Pushed by smartins into branch '1.4'.

empty-qstringliteral: Don't warn for uic generated files

Since 5.12 this is no longer an issue, since QStringLiteral
was abolished from ui_*.h files.

M  +17   -0    src/checks/level0/empty-qstringliteral.cpp
M  +1    -0    src/checks/level0/empty-qstringliteral.h
M  +1    -1    tests/empty-qstringliteral/main.cpp
A  +50   -0    tests/empty-qstringliteral/ui_qstringliteral.h     [License: GENERATED FILE]  *

The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


https://commits.kde.org/clazy/6e5fee3730ad2e443d9ec93eb88f06ee7f8b33e2
Comment 4 Evgeniy A. Dushistov 2018-10-09 11:01:09 UTC
Thank you.
Comment 5 Evgeniy A. Dushistov 2018-10-09 12:15:14 UTC
The problem is still here,

I suppose this is because of:

+    // Since 5.12 uic no longer uses QStringLiteral("")
+    if (preProcessorVisitor && preProcessorVisitor->qtVersion() >= 051200)
+        return false;

In my case preProcessorVisitor->qtVersion() return 51102,
but this is in decimal representation, in octet representation it is 0143636, and os it it bigger then 051200.

I suppose the right fix will be 51200, without '0' prefix.
Comment 6 Sergio Martins 2018-10-09 12:22:49 UTC
Git commit 2860f3dc6069b600383959563d5c5b475d523014 by Sergio Martins.
Committed on 09/10/2018 at 12:20.
Pushed by smartins into branch '1.4'.

Fix unintended octal value

M  +1    -1    src/checks/level0/empty-qstringliteral.cpp

https://commits.kde.org/clazy/2860f3dc6069b600383959563d5c5b475d523014
Comment 7 Sergio Martins 2018-10-09 12:23:32 UTC
try now, it should be fixed (branch 1.4)

thanks
Comment 8 Evgeniy A. Dushistov 2018-10-09 12:45:06 UTC
Thank you, now after long period of time I have zero warnings in my projects.
Comment 9 Sergio Martins 2018-10-14 16:59:47 UTC
Git commit 971c0cc4f3488c847746967450557c4fa390753b by Sergio Martins.
Committed on 09/10/2018 at 12:19.
Pushed by smartins into branch 'master'.

Fix unintended octal value

M  +1    -1    src/checks/level0/empty-qstringliteral.cpp

https://commits.kde.org/clazy/971c0cc4f3488c847746967450557c4fa390753b
Comment 10 Evgeniy A. Dushistov 2018-12-13 10:46:39 UTC
>  if (preProcessorVisitor && preProcessorVisitor->qtVersion() >= 51200)

At now I updated my system Qt to 5.12 and:

>ui_ValueCancelDialog.h:42:42: warning: Use QString instead of an empty QStringLiteral [-Wclazy-empty-qstringliteral]

So may be change 51200 to something like 59999 ?
Comment 11 Evgeniy A. Dushistov 2018-12-13 11:09:04 UTC
Sorry for noise, it was cache issue,
after clean rebuild ui_ files were generated without empty QStringLiteral