Skip to content

Commit bd0b43f

Browse files
committed
fix: fix clang tidy error
1 parent 1ecea8e commit bd0b43f

File tree

13 files changed

+38
-25
lines changed

13 files changed

+38
-25
lines changed

.github/workflows/clang_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ jobs:
4646
env:
4747
CC: clang
4848
CXX: clang++
49-
run: ci/scripts/build_paimon.sh $(pwd)
49+
run: ci/scripts/build_paimon.sh $(pwd) false true

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ if(PAIMON_LINT_GIT_DIFF_MODE)
118118
set(GIT_DIFF_FILE_PATH ${CMAKE_BINARY_DIR}/git_diff_files.txt)
119119
add_custom_target(update_diff_files
120120
# get git-diff file list
121-
COMMAND git diff-index --name-only --diff-filter=a --cached
121+
COMMAND git diff-index --name-only --diff-filter=d --cached
122122
${PAIMON_LINT_GIT_TARGET_COMMIT} > ${GIT_DIFF_FILE_PATH}
123123
# convert to absolute path
124124
COMMAND sed -i \"s|^|${CMAKE_SOURCE_DIR}/|\" ${GIT_DIFF_FILE_PATH}

ci/scripts/build_paimon.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set -eux
1818

1919
source_dir=${1}
2020
enable_sanitizer=${2:-false}
21+
check_clang_tidy=${3:-false}
2122
build_dir=${1}/build
2223

2324
mkdir ${build_dir}
@@ -42,6 +43,10 @@ cmake "${CMAKE_ARGS[@]}" ${source_dir}
4243
cmake --build . -- -j$(nproc)
4344
ctest --output-on-failure -j $(nproc)
4445

46+
if [[ "${check_clang_tidy}" == "true" ]]; then
47+
cmake --build . --target check-clang-tidy
48+
fi
49+
4550
popd
4651

4752
rm -rf ${build_dir}

include/paimon/result.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result {
3737
status_.~Status();
3838
}
3939

40+
// NOLINTBEGIN(google-explicit-constructor, runtime/explicit)
4041
/// Construct a successful result with a copy of the given value.
4142
/// @param data The value to store in result.
42-
Result(const T& data) : status_(), data_(data) {} // NOLINT(runtime/explicit)
43+
Result(const T& data) : status_(), data_(data) {}
4344

4445
/// Construct a successful result by moving the given value.
4546
/// @param data The value to move into result.
46-
Result(T&& data) : status_(), data_(std::move(data)) {} // NOLINT(runtime/explicit)
47+
Result(T&& data) : status_(), data_(std::move(data)) {}
4748

4849
/// Template constructor for converting compatible pointer types.
4950
/// Support T = std::unique_ptr<B> and U = std::unique_ptr<D> convert, where D is derived class
@@ -53,11 +54,12 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result {
5354
std::enable_if_t<
5455
is_pointer<U>::value && is_pointer<T>::value &&
5556
std::is_convertible_v<value_type_traits_t<U>, value_type_traits_t<T>>>* = nullptr>
56-
Result(U&& data) : status_(), data_(std::move(data)) {} // NOLINT(runtime/explicit)
57+
Result(U&& data) : status_(), data_(std::move(data)) {}
5758

5859
/// Construct a failed result with the given status.
5960
/// @param status The status object describing the error.
60-
Result(const Status& status) : status_(status) {} // NOLINT(runtime/explicit)
61+
Result(const Status& status) : status_(status) {}
62+
// NOLINTEND(google-explicit-constructor, runtime/explicit)
6163

6264
/// Copy constructor.
6365
/// @param other The result to copy from.
@@ -79,20 +81,22 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result {
7981
MakeStatus(other.status_);
8082
}
8183

84+
// NOLINTBEGIN(google-explicit-constructor, runtime/explicit)
8285
/// Template move constructor for converting compatible `Result` types.
8386
/// @param other The result to move from.
8487
template <typename U,
8588
std::enable_if_t<
8689
is_pointer<U>::value && is_pointer<T>::value &&
8790
std::is_convertible_v<value_type_traits_t<U>, value_type_traits_t<T>>>* = nullptr>
88-
Result(Result<U>&& other) noexcept { // NOLINT(runtime/explicit)
91+
Result(Result<U>&& other) noexcept {
8992
if (other.ok()) {
9093
MakeValue(std::move(other).value());
9194
}
9295
// If we moved the status, the other status may become ok but the other
9396
// value hasn't been constructed => crash on other destructor.
9497
MakeStatus(other.status());
9598
}
99+
// NOLINTEND(google-explicit-constructor, runtime/explicit)
96100

97101
/// Copy assignment operator.
98102
/// @param other The result to copy from.

src/paimon/common/data/binary_row_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ TEST_F(BinaryRowTest, TestBinaryRowSerializer) {
564564
test_string1.reserve(str_size);
565565
test_string2.reserve(str_size);
566566
for (int32_t j = 0; j < str_size; j++) {
567-
test_string1 += paimon::test::RandomNumber(0, 25) + 'a';
568-
test_string2 += paimon::test::RandomNumber(0, 25) + 'a';
567+
test_string1 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
568+
test_string2 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
569569
}
570570
std::shared_ptr<Bytes> bytes1 = Bytes::AllocateBytes(test_string1, pool.get());
571571
std::shared_ptr<Bytes> bytes2 = Bytes::AllocateBytes(test_string2, pool.get());

src/paimon/common/file_index/file_index_format_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ TEST_F(FileIndexFormatTest, TestSimple) {
149149
}
150150
}
151151

152+
// NOLINTNEXTLINE(google-readability-function-size)
152153
TEST_F(FileIndexFormatTest, TestBitmapIndexWithTimestamp) {
153154
auto schema = arrow::schema({
154155
arrow::field("ts_sec", arrow::timestamp(arrow::TimeUnit::SECOND)),

src/paimon/common/memory/memory_segment_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ TEST(MemorySegmentTest, TestSwapBytes) {
165165
test_string1.reserve(str_size);
166166
test_string2.reserve(str_size);
167167
for (int32_t j = 0; j < str_size; j++) {
168-
test_string1 += paimon::test::RandomNumber(0, 25) + 'a';
169-
test_string2 += paimon::test::RandomNumber(0, 25) + 'a';
168+
test_string1 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
169+
test_string2 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
170170
}
171171
std::shared_ptr<Bytes> bytes1 = Bytes::AllocateBytes(test_string1, pool.get());
172172
std::shared_ptr<Bytes> bytes2 = Bytes::AllocateBytes(test_string2, pool.get());

src/paimon/common/memory/memory_segment_utils_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ TEST(MemorySegmentUtilsTest, TestCopyFromBytesAndGetBytes) {
7171
test_string1.reserve(str_size);
7272
test_string2.reserve(str_size);
7373
for (int32_t j = 0; j < str_size; j++) {
74-
test_string1 += paimon::test::RandomNumber(0, 25) + 'a';
75-
test_string2 += paimon::test::RandomNumber(0, 25) + 'a';
74+
test_string1 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
75+
test_string2 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
7676
}
7777
test_string2 += test_string1;
7878
std::shared_ptr<Bytes> bytes1 = Bytes::AllocateBytes(test_string1, pool.get());
@@ -110,8 +110,8 @@ TEST(MemorySegmentUtilsTest, TestCopyToUnsafe) {
110110
test_string1.reserve(str_size);
111111
test_string2.reserve(str_size);
112112
for (int32_t j = 0; j < str_size; j++) {
113-
test_string1 += paimon::test::RandomNumber(0, 25) + 'a';
114-
test_string2 += paimon::test::RandomNumber(0, 25) + 'a';
113+
test_string1 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
114+
test_string2 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
115115
}
116116
test_string2 += test_string1;
117117
std::shared_ptr<Bytes> bytes1 = Bytes::AllocateBytes(test_string1, pool.get());
@@ -140,8 +140,8 @@ TEST(MemorySegmentUtilsTest, TestSetAndUnSet) {
140140
test_string1.reserve(str_size);
141141
test_string2.reserve(str_size);
142142
for (int32_t j = 0; j < str_size; j++) {
143-
test_string1 += paimon::test::RandomNumber(0, 25) + 'a';
144-
test_string2 += paimon::test::RandomNumber(0, 25) + 'a';
143+
test_string1 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
144+
test_string2 += std::to_string(paimon::test::RandomNumber(0, 25) + 'a');
145145
}
146146
test_string2 += test_string1;
147147
std::shared_ptr<Bytes> bytes2 = Bytes::AllocateBytes(test_string2, pool.get());

src/paimon/core/global_index/global_index_scan_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ Result<std::vector<Range>> GlobalIndexScanImpl::GetRowRangeList() {
7272
const auto& global_index_meta = entry.index_file->GetGlobalIndexMeta();
7373
assert(global_index_meta);
7474
const auto& index_meta = global_index_meta.value();
75-
index_ranges[entry.index_file->IndexType()].push_back(
76-
Range(index_meta.row_range_start, index_meta.row_range_end));
75+
index_ranges[entry.index_file->IndexType()].emplace_back(index_meta.row_range_start,
76+
index_meta.row_range_end);
7777
}
7878
std::string check_index_type;
7979
std::vector<Range> check_ranges;

src/paimon/core/operation/data_evolution_file_store_scan_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ TEST_F(DataEvolutionFileStoreScanTest, TestEvolutionStatsSingleFile) {
114114

115115
ASSERT_OK_AND_ASSIGN(auto result_stats, DataEvolutionFileStoreScan::EvolutionStats(
116116
{entry}, table_schema, schema_fetcher));
117-
ASSERT_EQ(result_stats.first, /*row_count=*/100);
117+
auto result_row_count = result_stats.first;
118+
ASSERT_EQ(result_row_count, 100);
118119
auto min_row = std::dynamic_pointer_cast<DataEvolutionRow>(result_stats.second.min_values);
119120
ASSERT_TRUE(min_row);
120121
auto max_row = std::dynamic_pointer_cast<DataEvolutionRow>(result_stats.second.max_values);
@@ -501,7 +502,8 @@ TEST_F(DataEvolutionFileStoreScanTest, TestEvolutionStatsWithBlob) {
501502
{blob_entry0, blob_entry1, entry0, entry1},
502503
table_schema, schema_fetcher));
503504

504-
ASSERT_EQ(result_stats.first, /*row_count=*/100);
505+
auto result_row_count = result_stats.first;
506+
ASSERT_EQ(result_row_count, 100);
505507
auto min_row = std::dynamic_pointer_cast<DataEvolutionRow>(result_stats.second.min_values);
506508
ASSERT_TRUE(min_row);
507509
auto max_row = std::dynamic_pointer_cast<DataEvolutionRow>(result_stats.second.max_values);

0 commit comments

Comments
 (0)