Skip to content

Commit eb6bf7e

Browse files
committed
suppress clang-tidy [google-explicit-constructor] in some cases where it is a false-positive
Signed-off-by: William Woodall <william@osrfoundation.org>
1 parent 28a7a8a commit eb6bf7e

6 files changed

Lines changed: 28 additions & 5 deletions

File tree

rclcpp/include/rclcpp/client.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct FutureAndRequestId
6161
{}
6262

6363
/// Allow implicit conversions to `std::future` by reference.
64+
// intentionally allow implicit conversions
65+
// NOLINTNEXTLINE(google-explicit-constructor)
6466
operator FutureT &() {return this->future;}
6567

6668
/// Deprecated, use the `future` member variable instead.
@@ -69,6 +71,8 @@ struct FutureAndRequestId
6971
* \deprecated
7072
*/
7173
[[deprecated("FutureAndRequestId: use .future instead of an implicit conversion")]]
74+
// intentionally allow implicit conversions
75+
// NOLINTNEXTLINE(google-explicit-constructor)
7276
operator FutureT() {return this->future;}
7377

7478
// delegate future like methods in the std::future impl_
@@ -284,6 +288,8 @@ class Client : public ClientBase
284288
*/
285289
[[deprecated(
286290
"FutureAndRequestId: use .future.share() instead of an implicit conversion")]]
291+
// intentionally allow implicit conversions
292+
// NOLINTNEXTLINE(google-explicit-constructor)
287293
operator SharedFuture() {return this->future.share();}
288294

289295
// delegate future like methods in the std::future impl_

rclcpp/include/rclcpp/duration.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ class RCLCPP_PUBLIC Duration
5151
// This constructor matches any std::chrono value other than nanoseconds
5252
// intentionally not using explicit to create a conversion constructor
5353
template<class Rep, class Period>
54+
// intentionally allow implicit conversions
5455
// cppcheck-suppress noExplicitConstructor
55-
Duration(const std::chrono::duration<Rep, Period> & duration) // NOLINT(runtime/explicit)
56+
// NOLINTNEXTLINE(runtime/explicit, google-explicit-constructor)
57+
Duration(const std::chrono::duration<Rep, Period> & duration)
5658
: Duration(std::chrono::duration_cast<std::chrono::nanoseconds>(duration))
5759
{}
5860

61+
// intentionally allow implicit conversions
5962
// cppcheck-suppress noExplicitConstructor
60-
Duration(const builtin_interfaces::msg::Duration & duration_msg); // NOLINT(runtime/explicit)
63+
// NOLINTNEXTLINE(runtime/explicit, google-explicit-constructor)
64+
Duration(const builtin_interfaces::msg::Duration & duration_msg);
6165

6266
/// Time constructor
6367
/**
@@ -69,6 +73,8 @@ class RCLCPP_PUBLIC Duration
6973

7074
virtual ~Duration() = default;
7175

76+
// intentionally allow implicit conversions
77+
// NOLINTNEXTLINE(google-explicit-constructor)
7278
operator builtin_interfaces::msg::Duration() const;
7379

7480
// cppcheck-suppress operatorEq // this is a false positive from cppcheck

rclcpp/include/rclcpp/loaned_message.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ class LoanedMessage
112112
: LoanedMessage(*pub, *allocator)
113113
{}
114114

115-
/// Move semantic for RVO
115+
/// Move constructor to support RVO.
116+
// move constructors should not be explicit
117+
// NOLINTNEXTLINE(google-explicit-constructor)
116118
LoanedMessage(LoanedMessage<MessageT> && other)
117119
: pub_(std::move(other.pub_)),
118120
message_(std::move(other.message_)),

rclcpp/include/rclcpp/message_info.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class RCLCPP_PUBLIC MessageInfo
3333
/**
3434
* \param[in] rmw_message_info message info to initialize the class
3535
*/
36+
// intentionally allow implicit conversions
3637
// cppcheck-suppress noExplicitConstructor
37-
MessageInfo(const rmw_message_info_t & rmw_message_info); // NOLINT(runtime/explicit)
38+
// NOLINTNEXTLINE(runtime/explicit, google-explicit-constructor)
39+
MessageInfo(const rmw_message_info_t & rmw_message_info);
3840

3941
virtual ~MessageInfo();
4042

rclcpp/include/rclcpp/qos.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ class RCLCPP_PUBLIC QoS
137137
* with a Publisher, or how many messages can be queued before being replaced
138138
* by a Subscription.
139139
*/
140+
// intentionally allow implicit conversions
140141
// cppcheck-suppress noExplicitConstructor
141-
QoS(size_t history_depth); // NOLINT(runtime/explicit): conversion constructor
142+
// NOLINTNEXTLINE(runtime/explicit, google-explicit-constructor)
143+
QoS(size_t history_depth);
142144

143145
/// Return the rmw qos profile.
144146
rmw_qos_profile_t &

rclcpp/include/rclcpp/time.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class Time
6464
* \throws std::runtime_error if seconds are negative
6565
*/
6666
RCLCPP_PUBLIC
67+
// intentionally allow implicit conversions
68+
// cppcheck-suppress noExplicitConstructor
69+
// NOLINTNEXTLINE(google-explicit-constructor)
6770
Time(
6871
const builtin_interfaces::msg::Time & time_msg,
6972
rcl_clock_type_t clock_type = RCL_ROS_TIME);
@@ -81,6 +84,8 @@ class Time
8184

8285
/// Return a builtin_interfaces::msg::Time object based
8386
RCLCPP_PUBLIC
87+
// intentionally allow implicit conversions
88+
// NOLINTNEXTLINE(google-explicit-constructor)
8489
operator builtin_interfaces::msg::Time() const;
8590

8691
/**

0 commit comments

Comments
 (0)