Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(pre-commit): update cpplint to 2.0.0 #9557

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ repos:
types_or: [c++, c, cuda]

- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
rev: 2.0.0
hooks:
- id: cpplint
args: [--quiet]
Expand Down
2 changes: 2 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ set noparent
linelength=100
includeorder=standardcfirst
filter=-build/c++11 # we do allow C++11
filter=-build/c++17 # we allow <filesystem>
filter=-build/namespaces_literals # we allow using namespace for literals
filter=-runtime/references # we consider passing non-const references to be ok
filter=-whitespace/braces # we wrap open curly braces for namespaces, classes and functions
filter=-whitespace/indent # we don't indent keywords like public, protected and private with one space
filter=-whitespace/newline # we allow the developer to decide about newline at the end of file (it's clashing with clang-format)
filter=-whitespace/parens # we allow closing parenthesis to be on the next line
filter=-whitespace/semicolon # we allow the developer to decide about whitespace after a semicolon
filter=-build/header_guard # we automatically fix the names of header guards using pre-commit
Expand Down
9 changes: 5 additions & 4 deletions common/autoware_test_utils/test/test_mock_data_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,12 @@
// Test parsing of segments
const auto segments = parse<std::vector<LaneletSegment>>(config["segments"]);
ASSERT_EQ(
segments.size(), uint64_t(1)); // Assuming only one segment in the provided YAML for this test
segments.size(),
static_cast<uint64_t>(1)); // Assuming only one segment in the provided YAML for this test

const auto & segment0 = segments[0];
EXPECT_EQ(segment0.preferred_primitive.id, 11);
EXPECT_EQ(segment0.primitives.size(), uint64_t(2));
EXPECT_EQ(segment0.primitives.size(), static_cast<uint64_t>(2));

Check warning on line 681 in common/autoware_test_utils/test/test_mock_data_parser.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Large Method

TEST:ParseFunctions:CompleteYAMLTest increases from 123 to 124 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
EXPECT_EQ(segment0.primitives[0].id, 22);
EXPECT_EQ(segment0.primitives[0].primitive_type, "lane");
EXPECT_EQ(segment0.primitives[1].id, 33);
Expand Down Expand Up @@ -811,10 +812,10 @@

ASSERT_EQ(
lanelet_route.segments.size(),
uint64_t(2)); // Assuming only one segment in the provided YAML for this test
static_cast<uint64_t>(2)); // Assuming only one segment in the provided YAML for this test
const auto & segment1 = lanelet_route.segments[1];
EXPECT_EQ(segment1.preferred_primitive.id, 44);
EXPECT_EQ(segment1.primitives.size(), uint64_t(4));
EXPECT_EQ(segment1.primitives.size(), static_cast<uint64_t>(4));
EXPECT_EQ(segment1.primitives[0].id, 55);
EXPECT_EQ(segment1.primitives[0].primitive_type, "lane");
EXPECT_EQ(segment1.primitives[1].id, 66);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include <gtest/gtest.h>

#include <vector>

using autoware::lane_departure_checker::utils::createVehiclePassingAreas;
using autoware::universe_utils::LinearRing2d;
using autoware::universe_utils::Point2d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ int32_t PurePursuit::findNextPointIdx(int32_t search_start_idx)
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
preprocess(*output_msg);

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

Check warning on line 218 in perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/fusion_node.cpp#L218

Added line #L218 was not covered by tests

// if matching rois exist, fuseOnSingle
// please ask maintainers before parallelize this loop because debugger is not thread safe
Expand All @@ -232,14 +232,17 @@
std::list<int64_t> outdate_stamps;

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

if (interval <= min_interval && interval <= match_threshold_ms_ * (int64_t)1e6) {
if (
interval <= min_interval && interval <= match_threshold_ms_ * static_cast<int64_t>(1e6)) {
min_interval = interval;
matched_stamp = k;
} else if (int64_t(k) < new_stamp && interval > match_threshold_ms_ * (int64_t)1e6) {
outdate_stamps.push_back(int64_t(k));
} else if (
static_cast<int64_t>(k) < new_stamp &&

Check warning on line 243 in perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/fusion_node.cpp#L243

Added line #L243 was not covered by tests
interval > match_threshold_ms_ * static_cast<int64_t>(1e6)) {
outdate_stamps.push_back(static_cast<int64_t>(k));
}
}

Expand Down Expand Up @@ -293,7 +296,7 @@
processing_time_ms = 0;
}
} else {
cached_msg_.first = int64_t(timestamp_nsec);
cached_msg_.first = timestamp_nsec;

Check warning on line 299 in perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

subCallback already has high cyclomatic complexity, and now it increases in Lines of Code from 106 to 109. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 299 in perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/fusion_node.cpp#L299

Added line #L299 was not covered by tests
cached_msg_.second = output_msg;
processing_time_ms = stop_watch_ptr_->toc("processing_time", true);
}
Expand All @@ -305,15 +308,16 @@
{
stop_watch_ptr_->toc("processing_time", true);

int64_t timestamp_nsec =
(*input_roi_msg).header.stamp.sec * (int64_t)1e9 + (*input_roi_msg).header.stamp.nanosec;
int64_t timestamp_nsec = (*input_roi_msg).header.stamp.sec * static_cast<int64_t>(1e9) +

Check warning on line 311 in perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/fusion_node.cpp#L311

Added line #L311 was not covered by tests
(*input_roi_msg).header.stamp.nanosec;

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

if (interval < match_threshold_ms_ * (int64_t)1e6 && is_fused_.at(roi_i) == false) {
if (
interval < match_threshold_ms_ * static_cast<int64_t>(1e6) && is_fused_.at(roi_i) == false) {
if (camera_info_map_.find(roi_i) == camera_info_map_.end()) {
RCLCPP_WARN_THROTTLE(
this->get_logger(), *this->get_clock(), 5000, "no camera info. id is %zu", roi_i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}

int64_t timestamp_nsec =
output_msg.header.stamp.sec * (int64_t)1e9 + output_msg.header.stamp.nanosec;
output_msg.header.stamp.sec * static_cast<int64_t>(1e9) + output_msg.header.stamp.nanosec;
passthrough_object_flags_map_.insert(std::make_pair(timestamp_nsec, passthrough_object_flags));
fused_object_flags_map_.insert(std::make_pair(timestamp_nsec, fused_object_flags));
ignored_object_flags_map_.insert(std::make_pair(timestamp_nsec, ignored_object_flags));
Expand Down Expand Up @@ -118,8 +118,8 @@
const image_geometry::PinholeCameraModel & pinhole_camera_model)
{
std::map<std::size_t, DetectedObjectWithFeature> object_roi_map;
int64_t timestamp_nsec =
input_object_msg.header.stamp.sec * (int64_t)1e9 + input_object_msg.header.stamp.nanosec;
int64_t timestamp_nsec = input_object_msg.header.stamp.sec * static_cast<int64_t>(1e9) +

Check warning on line 121 in perception/autoware_image_projection_based_fusion/src/roi_detected_object_fusion/node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/roi_detected_object_fusion/node.cpp#L121

Added line #L121 was not covered by tests
input_object_msg.header.stamp.nanosec;
if (passthrough_object_flags_map_.size() == 0) {
return object_roi_map;
}
Expand Down Expand Up @@ -205,8 +205,8 @@
const std::vector<DetectedObjectWithFeature> & image_rois,
const std::map<std::size_t, DetectedObjectWithFeature> & object_roi_map)
{
int64_t timestamp_nsec =
input_object_msg.header.stamp.sec * (int64_t)1e9 + input_object_msg.header.stamp.nanosec;
int64_t timestamp_nsec = input_object_msg.header.stamp.sec * static_cast<int64_t>(1e9) +

Check warning on line 208 in perception/autoware_image_projection_based_fusion/src/roi_detected_object_fusion/node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/roi_detected_object_fusion/node.cpp#L208

Added line #L208 was not covered by tests
input_object_msg.header.stamp.nanosec;
if (fused_object_flags_map_.size() == 0 || ignored_object_flags_map_.size() == 0) {
return;
}
Expand Down Expand Up @@ -289,7 +289,7 @@
}

int64_t timestamp_nsec =
output_msg.header.stamp.sec * (int64_t)1e9 + output_msg.header.stamp.nanosec;
output_msg.header.stamp.sec * static_cast<int64_t>(1e9) + output_msg.header.stamp.nanosec;
if (
passthrough_object_flags_map_.size() == 0 || fused_object_flags_map_.size() == 0 ||
ignored_object_flags_map_.size() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

#include <lanelet2_core/geometry/Polygon.h>

#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>

namespace autoware::behavior_velocity_planner
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ std::uint64_t ComponentMonitor::parse_memory_res(const std::string & mem_res)
{
// example 1: 12.3g
// example 2: 123 (without suffix, just bytes)
// NOLINTNEXTLINE(readability/casting)
static const std::unordered_map<char, std::function<std::uint64_t(double)>> unit_map{
xmfcx marked this conversation as resolved.
Show resolved Hide resolved
{'k', unit_conversions::kib_to_bytes<double>}, {'m', unit_conversions::mib_to_bytes<double>},
{'g', unit_conversions::gib_to_bytes<double>}, {'t', unit_conversions::tib_to_bytes<double>},
Expand Down
22 changes: 11 additions & 11 deletions system/system_monitor/reader/hdd_reader/hdd_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@
char data[4096]{}; // Fixed size for Identify command

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

Check warning on line 336 in system/system_monitor/reader/hdd_reader/hdd_reader.cpp

View check run for this annotation

Codecov / codecov/patch

system/system_monitor/reader/hdd_reader/hdd_reader.cpp#L333-L336

Added lines #L333 - L336 were not covered by tests

// send Admin Command to device
int ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
Expand Down Expand Up @@ -368,13 +368,13 @@
unsigned char data[144]{}; // 36 Dword (get byte 0 to 143)

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

Check warning on line 375 in system/system_monitor/reader/hdd_reader/hdd_reader.cpp

View check run for this annotation

Codecov / codecov/patch

system/system_monitor/reader/hdd_reader/hdd_reader.cpp#L371-L375

Added lines #L371 - L375 were not covered by tests
// - Minimum necessary size to obtain S.M.A.R.T. informations
// Bit 07:00 = 02h (SMART / Health Information)

// send Admin Command to device
int ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
Expand Down
Loading