Skip to content

Commit a1ec5a9

Browse files
GH-47167: [C++][Dev] Update clang-format dependency (#47168)
### Rationale for this change Update clang-format to better match modern IDEs. ### What changes are included in this PR? - Update clang-format - Reformat code base with newer version ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: #47167 Lead-authored-by: AntoinePrv <AntoinePrv@users.noreply.github.com> Co-authored-by: Rossi Sun <zanmato1984@gmail.com> Signed-off-by: Rossi Sun <zanmato1984@gmail.com>
1 parent 0ef674b commit a1ec5a9

32 files changed

+122
-138
lines changed

.github/workflows/dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141

4242
lint:
4343
name: Lint C++, Python, R, Docker, RAT
44-
# Use Ubuntu 22.04 to ensure working pre-commit on Ubuntu 22.04.
45-
runs-on: ubuntu-22.04
44+
# Use Ubuntu 24.04 to ensure working pre-commit on Ubuntu 24.04.
45+
runs-on: ubuntu-24.04
4646
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
4747
timeout-minutes: 15
4848
steps:

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ repos:
5050
)
5151
types: []
5252
- repo: https://github.com/pre-commit/mirrors-clang-format
53-
rev: v14.0.6
53+
rev: v18.1.8
5454
hooks:
5555
- id: clang-format
5656
name: C++ Format
@@ -93,15 +93,15 @@ repos:
9393
?^cpp/thirdparty/|
9494
)
9595
- repo: https://github.com/pre-commit/mirrors-clang-format
96-
rev: v14.0.6
96+
rev: v18.1.8
9797
hooks:
9898
- id: clang-format
9999
alias: c-glib
100100
name: C/GLib Format
101101
files: >-
102102
^c_glib/
103103
- repo: https://github.com/pre-commit/mirrors-clang-format
104-
rev: v14.0.6
104+
rev: v18.1.8
105105
hooks:
106106
- id: clang-format
107107
name: MATLAB (C++) Format
@@ -156,7 +156,7 @@ repos:
156156
files: >-
157157
^python/
158158
- repo: https://github.com/pre-commit/mirrors-clang-format
159-
rev: v14.0.6
159+
rev: v18.1.8
160160
hooks:
161161
- id: clang-format
162162
alias: python
@@ -213,7 +213,7 @@ repos:
213213
files: >-
214214
^r/.*\.R$
215215
- repo: https://github.com/pre-commit/mirrors-clang-format
216-
rev: v14.0.6
216+
rev: v18.1.8
217217
hooks:
218218
- id: clang-format
219219
alias: r

cpp/src/arrow/acero/exec_plan.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct ExecPlanImpl : public ExecPlan {
137137
opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> span =
138138
::arrow::internal::tracing::UnwrapSpan(span_.details.get());
139139
std::for_each(std::begin(pairs), std::end(pairs),
140-
[span](std::pair<std::string, std::string> const& pair) {
140+
[span](const std::pair<std::string, std::string>& pair) {
141141
span->SetAttribute(pair.first, pair.second);
142142
});
143143
}

cpp/src/arrow/compute/kernels/aggregate_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,8 +3889,7 @@ class TestPrimitiveQuantileKernel : public ::testing::Test {
38893889
#define INTYPE(x) Datum(static_cast<typename TypeParam::c_type>(x))
38903890
#define DOUBLE(x) Datum(static_cast<double>(x))
38913891
// output type per interpolation: linear, lower, higher, nearest, midpoint
3892-
#define O(a, b, c, d, e) \
3893-
{ DOUBLE(a), INTYPE(b), INTYPE(c), INTYPE(d), DOUBLE(e) }
3892+
#define O(a, b, c, d, e) {DOUBLE(a), INTYPE(b), INTYPE(c), INTYPE(d), DOUBLE(e)}
38943893

38953894
template <typename ArrowType>
38963895
class TestIntegerQuantileKernel : public TestPrimitiveQuantileKernel<ArrowType> {};

cpp/src/arrow/compute/kernels/hash_aggregate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ concept CFloatingPointConcept = std::floating_point<T> || std::same_as<T, util::
282282

283283
template <typename T>
284284
concept CDecimalConcept = std::same_as<T, Decimal32> || std::same_as<T, Decimal64> ||
285-
std::same_as<T, Decimal128> || std::same_as<T, Decimal256>;
285+
std::same_as<T, Decimal128> || std::same_as<T, Decimal256>;
286286

287287
template <typename CType>
288288
struct AntiExtrema {

cpp/src/arrow/compute/kernels/temporal_internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ using std::chrono::duration_cast;
4545
using ArrowTimeZone = std::variant<const time_zone*, OffsetZone>;
4646

4747
template <class Duration, class Func>
48-
auto ApplyTimeZone(const ArrowTimeZone& tz, sys_time<Duration> st, Func&& func)
49-
-> decltype(func(zoned_time<Duration>{})) {
48+
auto ApplyTimeZone(const ArrowTimeZone& tz, sys_time<Duration> st,
49+
Func&& func) -> decltype(func(zoned_time<Duration>{})) {
5050
return std::visit(
5151
[&](auto&& zone) {
5252
if constexpr (std::is_pointer_v<std::decay_t<decltype(zone)> >) {
@@ -60,8 +60,8 @@ auto ApplyTimeZone(const ArrowTimeZone& tz, sys_time<Duration> st, Func&& func)
6060

6161
template <class Duration, class Func>
6262
auto ApplyTimeZone(const ArrowTimeZone& tz, local_time<Duration> lt,
63-
std::optional<choose> c, Func&& func)
64-
-> decltype(func(zoned_time<Duration>{})) {
63+
std::optional<choose> c,
64+
Func&& func) -> decltype(func(zoned_time<Duration>{})) {
6565
return std::visit(
6666
[&](auto&& zone) {
6767
if constexpr (std::is_pointer_v<std::decay_t<decltype(zone)> >) {

cpp/src/arrow/compute/kernels/vector_selection_filter_internal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class PrimitiveFilterImpl {
368368
}
369369
}
370370
} // !filter_block.AllSet()
371-
} // while(in_position < values_length_)
371+
} // while(in_position < values_length_)
372372
}
373373

374374
// Write the next out_position given the selected in_position for the input

cpp/src/arrow/compute/kernels/vector_sort_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ std::ostream& operator<<(std::ostream& os, NullPlacement null_placement) {
7676
// Tests for NthToIndices
7777

7878
template <typename ArrayType>
79-
auto GetLogicalValue(const ArrayType& array, uint64_t index)
80-
-> decltype(array.GetView(index)) {
79+
auto GetLogicalValue(const ArrayType& array,
80+
uint64_t index) -> decltype(array.GetView(index)) {
8181
return array.GetView(index);
8282
}
8383

cpp/src/arrow/dataset/dataset_writer_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ TEST_F(DatasetWriterTestFixture, ErrOnExistingData) {
613613
fs::File("testdir/chunk-5.arrow"), fs::File("testdir/blah.txt")}));
614614
filesystem_ = std::dynamic_pointer_cast<MockFileSystem>(fs);
615615
write_options_.filesystem = filesystem_;
616-
ASSERT_RAISES(Invalid, DatasetWriter::Make(
617-
write_options_, scheduler_, [] {}, [] {}, [] {}));
616+
ASSERT_RAISES(Invalid,
617+
DatasetWriter::Make(write_options_, scheduler_, [] {}, [] {}, [] {}));
618618
AssertEmptyFiles(
619619
{"testdir/chunk-0.arrow", "testdir/chunk-5.arrow", "testdir/blah.txt"});
620620

@@ -627,8 +627,8 @@ TEST_F(DatasetWriterTestFixture, ErrOnExistingData) {
627627
filesystem_ = std::dynamic_pointer_cast<MockFileSystem>(fs2);
628628
write_options_.filesystem = filesystem_;
629629
write_options_.base_dir = "testdir";
630-
ASSERT_RAISES(Invalid, DatasetWriter::Make(
631-
write_options_, scheduler_, [] {}, [] {}, [] {}));
630+
ASSERT_RAISES(Invalid,
631+
DatasetWriter::Make(write_options_, scheduler_, [] {}, [] {}, [] {}));
632632
AssertEmptyFiles({"testdir/part-0.arrow"});
633633
}
634634

cpp/src/arrow/dataset/file_test.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,12 @@ class FileSystemWriteTest : public testing::TestWithParam<std::tuple<bool, bool>
594594
};
595595

596596
TEST_P(FileSystemWriteTest, Write) {
597-
auto plan_factory = [](const FileSystemDatasetWriteOptions& write_options,
598-
std::function<Future<std::optional<cp::ExecBatch>>()>*
599-
sink_gen) {
600-
return std::vector<acero::Declaration>{{"write", WriteNodeOptions{write_options}}};
601-
};
597+
auto plan_factory =
598+
[](const FileSystemDatasetWriteOptions& write_options,
599+
std::function<Future<std::optional<cp::ExecBatch>>()>* sink_gen) {
600+
return std::vector<acero::Declaration>{
601+
{"write", WriteNodeOptions{write_options}}};
602+
};
602603
TestDatasetWriteRoundTrip(plan_factory, /*has_output=*/false);
603604
}
604605

0 commit comments

Comments
 (0)