Bug 384926 - ctor-missing-parent-argument for subclasses of QCoreApplication
Summary: ctor-missing-parent-argument for subclasses of QCoreApplication
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: 2017-09-21 10:45 UTC by Markus Enzenberger
Modified: 2017-09-21 21:44 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 Markus Enzenberger 2017-09-21 10:45:29 UTC
Clazy warns with ctor-missing-parent-argument for subclasses of QCoreApplication, but the base class QCoreApplication has no constructor that takes a parent object.

The Qt documentation explicitely mentions use cases for creating subclasses of QCoreApplication, for example to override QCoreApplication::notify().

Would it be difficult for Clazy to detect if the base class is QCoreApplication and suppress the warning in this case?
Comment 1 Sergio Martins 2017-09-21 14:11:17 UTC
clazy shouldn't warn for any base class that lives in a system header, such as QCoreApplication
Comment 2 Markus Enzenberger 2017-09-21 14:56:16 UTC
(In reply to Sergio Martins from comment #1)
> clazy shouldn't warn for any base class that lives in a system header, such
> as QCoreApplication

sure, but I'm saying it should also not warn for the subclass. It doesn't make much sense to write a constructor with a parent argument for subclasses of QCoreApplication.
Comment 3 Markus Enzenberger 2017-09-21 14:59:03 UTC
(In reply to Markus Enzenberger from comment #2)
> (In reply to Sergio Martins from comment #1)
> > clazy shouldn't warn for any base class that lives in a system header, such
> > as QCoreApplication
> 
> sure, but I'm saying it should also not warn for the subclass. It doesn't
> make much sense to write a constructor with a parent argument for subclasses
> of QCoreApplication.

just to be explicit: I mean subclasses written by the user, not in Qt headers.
Comment 4 Sergio Martins 2017-09-21 15:04:32 UTC
Git commit 641ef2cf56a5d8e64e43a46e01aee0efd354215a by Sergio Martins.
Committed on 21/09/2017 at 15:04.
Pushed by smartins into branch '1.2'.

ctor-missing-parent-argument: Add a failing unit-test

M  +2    -1    tests/ctor-missing-parent-argument/config.json
M  +7    -0    tests/ctor-missing-parent-argument/main.cpp

https://commits.kde.org/clazy/641ef2cf56a5d8e64e43a46e01aee0efd354215a
Comment 5 Sergio Martins 2017-09-21 21:44:06 UTC
Git commit b843957a8dd3fc24ecdaae0289d976a08a0e6958 by Sergio Martins.
Committed on 21/09/2017 at 21:42.
Pushed by smartins into branch '1.2'.

ctor-missing-parent-argument: Don't warn when base class is in system header

and doesn't accept any QObject in any ctor.

M  +10   -0    src/checks/level1/ctor-missing-parent-argument.cpp
M  +1    -2    tests/ctor-missing-parent-argument/config.json

https://commits.kde.org/clazy/b843957a8dd3fc24ecdaae0289d976a08a0e6958