Skip to content

Commit 53a960e

Browse files
ci(pre-commit): update cpplint to 2.0.0 (#9557)
Signed-off-by: M. Fatih Cırıt <mfc@autoware.org>
1 parent 1aba360 commit 53a960e

File tree

10 files changed

+51
-35
lines changed

10 files changed

+51
-35
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ repos:
7676
types_or: [c++, c, cuda]
7777

7878
- repo: https://github.com/cpplint/cpplint
79-
rev: 1.6.1
79+
rev: 2.0.0
8080
hooks:
8181
- id: cpplint
8282
args: [--quiet]

CPPLINT.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ set noparent
77
linelength=100
88
includeorder=standardcfirst
99
filter=-build/c++11 # we do allow C++11
10+
filter=-build/c++17 # we allow <filesystem>
1011
filter=-build/namespaces_literals # we allow using namespace for literals
1112
filter=-runtime/references # we consider passing non-const references to be ok
1213
filter=-whitespace/braces # we wrap open curly braces for namespaces, classes and functions
1314
filter=-whitespace/indent # we don't indent keywords like public, protected and private with one space
15+
filter=-whitespace/newline # we allow the developer to decide about newline at the end of file (it's clashing with clang-format)
1416
filter=-whitespace/parens # we allow closing parenthesis to be on the next line
1517
filter=-whitespace/semicolon # we allow the developer to decide about whitespace after a semicolon
1618
filter=-build/header_guard # we automatically fix the names of header guards using pre-commit

common/autoware_test_utils/test/test_mock_data_parser.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,12 @@ TEST(ParseFunctions, CompleteYAMLTest)
673673
// Test parsing of segments
674674
const auto segments = parse<std::vector<LaneletSegment>>(config["segments"]);
675675
ASSERT_EQ(
676-
segments.size(), uint64_t(1)); // Assuming only one segment in the provided YAML for this test
676+
segments.size(),
677+
static_cast<uint64_t>(1)); // Assuming only one segment in the provided YAML for this test
677678

678679
const auto & segment0 = segments[0];
679680
EXPECT_EQ(segment0.preferred_primitive.id, 11);
680-
EXPECT_EQ(segment0.primitives.size(), uint64_t(2));
681+
EXPECT_EQ(segment0.primitives.size(), static_cast<uint64_t>(2));
681682
EXPECT_EQ(segment0.primitives[0].id, 22);
682683
EXPECT_EQ(segment0.primitives[0].primitive_type, "lane");
683684
EXPECT_EQ(segment0.primitives[1].id, 33);
@@ -811,10 +812,10 @@ TEST(ParseFunction, CompleteFromFilename)
811812

812813
ASSERT_EQ(
813814
lanelet_route.segments.size(),
814-
uint64_t(2)); // Assuming only one segment in the provided YAML for this test
815+
static_cast<uint64_t>(2)); // Assuming only one segment in the provided YAML for this test
815816
const auto & segment1 = lanelet_route.segments[1];
816817
EXPECT_EQ(segment1.preferred_primitive.id, 44);
817-
EXPECT_EQ(segment1.primitives.size(), uint64_t(4));
818+
EXPECT_EQ(segment1.primitives.size(), static_cast<uint64_t>(4));
818819
EXPECT_EQ(segment1.primitives[0].id, 55);
819820
EXPECT_EQ(segment1.primitives[0].primitive_type, "lane");
820821
EXPECT_EQ(segment1.primitives[1].id, 66);

control/autoware_lane_departure_checker/test/test_create_vehicle_passing_areas.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <gtest/gtest.h>
2626

27+
#include <vector>
28+
2729
using autoware::lane_departure_checker::utils::createVehiclePassingAreas;
2830
using autoware::universe_utils::LinearRing2d;
2931
using autoware::universe_utils::Point2d;

control/autoware_pure_pursuit/src/autoware_pure_pursuit_core/autoware_pure_pursuit.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ int32_t PurePursuit::findNextPointIdx(int32_t search_start_idx)
156156
}
157157

158158
// look for the next waypoint.
159-
for (int32_t i = search_start_idx; i < (int32_t)curr_wps_ptr_->size(); i++) {
159+
for (int32_t i = search_start_idx; i < static_cast<int32_t>(curr_wps_ptr_->size()); i++) {
160160
// if search waypoint is the last
161-
if (i == ((int32_t)curr_wps_ptr_->size() - 1)) {
161+
if (i == (static_cast<int32_t>(curr_wps_ptr_->size()) - 1)) {
162162
return i;
163163
}
164164

perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void FusionNode<TargetMsg3D, Obj, Msg2D>::subCallback(
215215
preprocess(*output_msg);
216216

217217
int64_t timestamp_nsec =
218-
(*output_msg).header.stamp.sec * (int64_t)1e9 + (*output_msg).header.stamp.nanosec;
218+
(*output_msg).header.stamp.sec * static_cast<int64_t>(1e9) + (*output_msg).header.stamp.nanosec;
219219

220220
// if matching rois exist, fuseOnSingle
221221
// please ask maintainers before parallelize this loop because debugger is not thread safe
@@ -232,14 +232,17 @@ void FusionNode<TargetMsg3D, Obj, Msg2D>::subCallback(
232232
std::list<int64_t> outdate_stamps;
233233

234234
for (const auto & [k, v] : cached_roi_msgs_.at(roi_i)) {
235-
int64_t new_stamp = timestamp_nsec + input_offset_ms_.at(roi_i) * (int64_t)1e6;
236-
int64_t interval = abs(int64_t(k) - new_stamp);
235+
int64_t new_stamp = timestamp_nsec + input_offset_ms_.at(roi_i) * static_cast<int64_t>(1e6);
236+
int64_t interval = abs(static_cast<int64_t>(k) - new_stamp);
237237

238-
if (interval <= min_interval && interval <= match_threshold_ms_ * (int64_t)1e6) {
238+
if (
239+
interval <= min_interval && interval <= match_threshold_ms_ * static_cast<int64_t>(1e6)) {
239240
min_interval = interval;
240241
matched_stamp = k;
241-
} else if (int64_t(k) < new_stamp && interval > match_threshold_ms_ * (int64_t)1e6) {
242-
outdate_stamps.push_back(int64_t(k));
242+
} else if (
243+
static_cast<int64_t>(k) < new_stamp &&
244+
interval > match_threshold_ms_ * static_cast<int64_t>(1e6)) {
245+
outdate_stamps.push_back(static_cast<int64_t>(k));
243246
}
244247
}
245248

@@ -293,7 +296,7 @@ void FusionNode<TargetMsg3D, Obj, Msg2D>::subCallback(
293296
processing_time_ms = 0;
294297
}
295298
} else {
296-
cached_msg_.first = int64_t(timestamp_nsec);
299+
cached_msg_.first = timestamp_nsec;
297300
cached_msg_.second = output_msg;
298301
processing_time_ms = stop_watch_ptr_->toc("processing_time", true);
299302
}
@@ -305,15 +308,16 @@ void FusionNode<TargetMsg3D, Obj, Msg2D>::roiCallback(
305308
{
306309
stop_watch_ptr_->toc("processing_time", true);
307310

308-
int64_t timestamp_nsec =
309-
(*input_roi_msg).header.stamp.sec * (int64_t)1e9 + (*input_roi_msg).header.stamp.nanosec;
311+
int64_t timestamp_nsec = (*input_roi_msg).header.stamp.sec * static_cast<int64_t>(1e9) +
312+
(*input_roi_msg).header.stamp.nanosec;
310313

311314
// if cached Msg exist, try to match
312315
if (cached_msg_.second != nullptr) {
313-
int64_t new_stamp = cached_msg_.first + input_offset_ms_.at(roi_i) * (int64_t)1e6;
316+
int64_t new_stamp = cached_msg_.first + input_offset_ms_.at(roi_i) * static_cast<int64_t>(1e6);
314317
int64_t interval = abs(timestamp_nsec - new_stamp);
315318

316-
if (interval < match_threshold_ms_ * (int64_t)1e6 && is_fused_.at(roi_i) == false) {
319+
if (
320+
interval < match_threshold_ms_ * static_cast<int64_t>(1e6) && is_fused_.at(roi_i) == false) {
317321
if (camera_info_map_.find(roi_i) == camera_info_map_.end()) {
318322
RCLCPP_WARN_THROTTLE(
319323
this->get_logger(), *this->get_clock(), 5000, "no camera info. id is %zu", roi_i);

perception/autoware_image_projection_based_fusion/src/roi_detected_object_fusion/node.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void RoiDetectedObjectFusionNode::preprocess(DetectedObjects & output_msg)
6969
}
7070

7171
int64_t timestamp_nsec =
72-
output_msg.header.stamp.sec * (int64_t)1e9 + output_msg.header.stamp.nanosec;
72+
output_msg.header.stamp.sec * static_cast<int64_t>(1e9) + output_msg.header.stamp.nanosec;
7373
passthrough_object_flags_map_.insert(std::make_pair(timestamp_nsec, passthrough_object_flags));
7474
fused_object_flags_map_.insert(std::make_pair(timestamp_nsec, fused_object_flags));
7575
ignored_object_flags_map_.insert(std::make_pair(timestamp_nsec, ignored_object_flags));
@@ -118,8 +118,8 @@ RoiDetectedObjectFusionNode::generateDetectedObjectRoIs(
118118
const image_geometry::PinholeCameraModel & pinhole_camera_model)
119119
{
120120
std::map<std::size_t, DetectedObjectWithFeature> object_roi_map;
121-
int64_t timestamp_nsec =
122-
input_object_msg.header.stamp.sec * (int64_t)1e9 + input_object_msg.header.stamp.nanosec;
121+
int64_t timestamp_nsec = input_object_msg.header.stamp.sec * static_cast<int64_t>(1e9) +
122+
input_object_msg.header.stamp.nanosec;
123123
if (passthrough_object_flags_map_.size() == 0) {
124124
return object_roi_map;
125125
}
@@ -205,8 +205,8 @@ void RoiDetectedObjectFusionNode::fuseObjectsOnImage(
205205
const std::vector<DetectedObjectWithFeature> & image_rois,
206206
const std::map<std::size_t, DetectedObjectWithFeature> & object_roi_map)
207207
{
208-
int64_t timestamp_nsec =
209-
input_object_msg.header.stamp.sec * (int64_t)1e9 + input_object_msg.header.stamp.nanosec;
208+
int64_t timestamp_nsec = input_object_msg.header.stamp.sec * static_cast<int64_t>(1e9) +
209+
input_object_msg.header.stamp.nanosec;
210210
if (fused_object_flags_map_.size() == 0 || ignored_object_flags_map_.size() == 0) {
211211
return;
212212
}
@@ -289,7 +289,7 @@ void RoiDetectedObjectFusionNode::publish(const DetectedObjects & output_msg)
289289
}
290290

291291
int64_t timestamp_nsec =
292-
output_msg.header.stamp.sec * (int64_t)1e9 + output_msg.header.stamp.nanosec;
292+
output_msg.header.stamp.sec * static_cast<int64_t>(1e9) + output_msg.header.stamp.nanosec;
293293
if (
294294
passthrough_object_flags_map_.size() == 0 || fused_object_flags_map_.size() == 0 ||
295295
ignored_object_flags_map_.size() == 0) {

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/src/util.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
#include <lanelet2_core/geometry/Polygon.h>
2424

25+
#include <algorithm>
26+
#include <memory>
27+
#include <string>
28+
#include <utility>
29+
#include <vector>
30+
2531
namespace autoware::behavior_velocity_planner
2632
{
2733

system/autoware_component_monitor/src/component_monitor_node.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ std::uint64_t ComponentMonitor::parse_memory_res(const std::string & mem_res)
147147
{
148148
// example 1: 12.3g
149149
// example 2: 123 (without suffix, just bytes)
150+
// NOLINTNEXTLINE(readability/casting)
150151
static const std::unordered_map<char, std::function<std::uint64_t(double)>> unit_map{
151152
{'k', unit_conversions::kib_to_bytes<double>}, {'m', unit_conversions::mib_to_bytes<double>},
152153
{'g', unit_conversions::gib_to_bytes<double>}, {'t', unit_conversions::tib_to_bytes<double>},

system/system_monitor/reader/hdd_reader/hdd_reader.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ int get_nvme_identify(int fd, HddInfo * info)
330330
char data[4096]{}; // Fixed size for Identify command
331331

332332
// The Identify command returns a data buffer that describes information about the NVM subsystem
333-
cmd.opcode = 0x06; // Identify
334-
cmd.addr = (uint64_t)data; // memory address of data
335-
cmd.data_len = sizeof(data); // length of data
336-
cmd.cdw10 = 0x01; // Identify Controller data structure
333+
cmd.opcode = 0x06; // Identify
334+
cmd.addr = reinterpret_cast<uint64_t>(data); // memory address of data
335+
cmd.data_len = sizeof(data); // length of data
336+
cmd.cdw10 = 0x01; // Identify Controller data structure
337337

338338
// send Admin Command to device
339339
int ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
@@ -368,13 +368,13 @@ int get_nvme_smart_data(int fd, HddInfo * info)
368368
unsigned char data[144]{}; // 36 Dword (get byte 0 to 143)
369369

370370
// The Get Log Page command returns a data buffer containing the log page requested
371-
cmd.opcode = 0x02; // Get Log Page
372-
cmd.nsid = 0xFFFFFFFF; // Global log page
373-
cmd.addr = (uint64_t)data; // memory address of data
374-
cmd.data_len = sizeof(data); // length of data
375-
cmd.cdw10 = 0x00240002; // Bit 27:16 Number of Dwords (NUMD) = 024h (36 Dword)
376-
// - Minimum necessary size to obtain S.M.A.R.T. informations
377-
// Bit 07:00 = 02h (SMART / Health Information)
371+
cmd.opcode = 0x02; // Get Log Page
372+
cmd.nsid = 0xFFFFFFFF; // Global log page
373+
cmd.addr = reinterpret_cast<uint64_t>(data); // memory address of data
374+
cmd.data_len = sizeof(data); // length of data
375+
cmd.cdw10 = 0x00240002; // Bit 27:16 Number of Dwords (NUMD) = 024h (36 Dword)
376+
// - Minimum necessary size to obtain S.M.A.R.T. informations
377+
// Bit 07:00 = 02h (SMART / Health Information)
378378

379379
// send Admin Command to device
380380
int ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);

0 commit comments

Comments
 (0)