Bug 385801 - favor function taking or returning std::chrono types
Summary: favor function taking or returning std::chrono types
Status: CONFIRMED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-16 08:21 UTC by eric.lemanissier
Modified: 2018-03-24 12:18 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 eric.lemanissier 2017-10-16 08:21:44 UTC
Some members function of Qt classes have one overload taking time as plain integer, and another taking time as std::chrono::duration or std::chrono::time_point. Plain integers are error prone, because the unit is implicit, so one must refer to the doc to make sure there is no error. Clazy could warn the usage of the plain integer overloads, and propose a fixit. 
in QTimer: setInterval, singleShot, start
in QDeadlineTimer: Constructor, operator=, setDeadline, setRemainingTime, operator+, operator+=
in QMutex: tryLock can be replaced with try_lock_for or try_lock_until
QObject::startTimer

The other case which could be ambiguous is function returning integer, which can be replaced with another returning a std::chrono::duration
in QTimer, interval can be replaced with intervalAsDuration. remainingTime can be replaced with remainingTimeAsDuration
in QDeadLineTimer deadline can be replaced with templated deadline. remainingTime and remainingTimeNSecs can be replaced with remainingTimeAsDuration