This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 9ad675d3d ci: update the version of clang-tidy to 18 (#3237)
9ad675d3d is described below
commit 9ad675d3d20584f9e677c49aba26f414e6eabc8a
Author: Twice <[email protected]>
AuthorDate: Mon Oct 27 16:39:24 2025 +0800
ci: update the version of clang-tidy to 18 (#3237)
This is a follow-up PR of #322.
---
.clang-tidy | 2 ++
.github/workflows/kvrocks.yaml | 4 ++--
src/cluster/batch_sender.h | 4 ++--
src/commands/cmd_geo.cc | 4 ++--
src/commands/cmd_timeseries.cc | 2 ++
src/commands/commander.h | 6 +++++-
src/common/cron.h | 4 ++--
src/config/config_type.h | 2 +-
src/search/hnsw_indexer.cc | 8 ++++----
src/types/redis_geo.cc | 2 +-
x.py | 2 +-
11 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 09e05a96d..d1719f51e 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -50,3 +50,5 @@ CheckOptions:
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: CamelCase
+ - key: readability-simplify-boolean-expr.IgnoreMacros
+ value: True
diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml
index ca4f06a11..1a91a2249 100644
--- a/.github/workflows/kvrocks.yaml
+++ b/.github/workflows/kvrocks.yaml
@@ -79,14 +79,14 @@ jobs:
- name: Prepare Dependencies
run: |
sudo apt update
- sudo apt install -y clang-format-18 clang-tidy-14
+ sudo apt install -y clang-format-18 clang-tidy-18
- name: Check with clang-format
id: check-format
run: ./x.py check format --clang-format-path clang-format-18
- name: Check with clang-tidy
run: |
./x.py build --skip-build
- ./x.py check tidy -j $(nproc) --clang-tidy-path clang-tidy-14
--run-clang-tidy-path run-clang-tidy-14
+ ./x.py check tidy -j $(nproc) --clang-tidy-path clang-tidy-18
--run-clang-tidy-path run-clang-tidy-18
- name: Lint with golangci-lint
run: ./x.py check golangci-lint
- name: Prepare format patch
diff --git a/src/cluster/batch_sender.h b/src/cluster/batch_sender.h
index 41f46d1f2..07c4e9fdb 100644
--- a/src/cluster/batch_sender.h
+++ b/src/cluster/batch_sender.h
@@ -56,8 +56,8 @@ class BatchSender {
private:
static Status sendApplyBatchCmd(int fd, const rocksdb::WriteBatch
&write_batch);
- rocksdb::WriteBatch write_batch_{};
- std::string prefix_logdata_{};
+ rocksdb::WriteBatch write_batch_;
+ std::string prefix_logdata_;
uint64_t sent_bytes_ = 0;
uint32_t sent_batches_num_ = 0;
uint32_t entries_num_ = 0;
diff --git a/src/commands/cmd_geo.cc b/src/commands/cmd_geo.cc
index 4c3546115..d6f7921d1 100644
--- a/src/commands/cmd_geo.cc
+++ b/src/commands/cmd_geo.cc
@@ -328,7 +328,7 @@ class CommandGeoRadius : public CommandGeoBase {
int returned_items_count = (count_ == 0 || result_length < count_) ?
result_length : count_;
std::vector<std::string> list;
for (int i = 0; i < returned_items_count; i++) {
- auto geo_point = geo_points[i];
+ const auto &geo_point = geo_points[i];
if (!with_coord_ && !with_hash_ && !with_dist_) {
list.emplace_back(redis::BulkString(geo_point.member));
} else {
@@ -525,7 +525,7 @@ class CommandGeoSearch : public CommandGeoBase {
std::vector<std::string> output;
output.reserve(returned_items_count);
for (int i = 0; i < returned_items_count; i++) {
- auto geo_point = geo_points[i];
+ const auto &geo_point = geo_points[i];
if (!with_coord_ && !with_hash_ && !with_dist_) {
output.emplace_back(redis::BulkString(geo_point.member));
} else {
diff --git a/src/commands/cmd_timeseries.cc b/src/commands/cmd_timeseries.cc
index add0113c0..b1ba01984 100644
--- a/src/commands/cmd_timeseries.cc
+++ b/src/commands/cmd_timeseries.cc
@@ -919,6 +919,7 @@ class CommandTSMGet : public CommandTSMGetBase {
entry[0] = redis::BulkString(result.name);
entry[1] = FormatTSLabelListAsRedisReply(result.labels);
std::vector<std::string> temp;
+ temp.reserve(result.samples.size());
for (auto &sample : result.samples) {
temp.push_back(FormatTSSampleAsRedisReply(sample));
}
@@ -976,6 +977,7 @@ class CommandTSMRange : public CommandTSRangeBase, public
CommandTSMGetBase {
}
entry[1] = FormatTSLabelListAsRedisReply(result.labels);
std::vector<std::string> temp;
+ temp.reserve(result.samples.size());
for (auto &sample : result.samples) {
temp.push_back(FormatTSSampleAsRedisReply(sample));
}
diff --git a/src/commands/commander.h b/src/commands/commander.h
index 7fede573f..2179387de 100644
--- a/src/commands/commander.h
+++ b/src/commands/commander.h
@@ -276,7 +276,11 @@ struct CommandAttributes {
}
bool CheckArity(int cmd_size) const {
- return !((arity > 0 && cmd_size != arity) || (arity < 0 && cmd_size <
-arity));
+ if (arity >= 0) {
+ return cmd_size == arity;
+ } else {
+ return cmd_size >= -arity;
+ }
}
StatusOr<CommandKeyRange> InitialKeyRange() const {
diff --git a/src/common/cron.h b/src/common/cron.h
index 920c25931..99cf1f965 100644
--- a/src/common/cron.h
+++ b/src/common/cron.h
@@ -71,11 +71,11 @@ struct CronPattern {
if (l >= r) {
return {Status::NotOK, "for pattern `l-r` in cron expression, r
should be larger than l"};
}
- results.push_back(Range(l, r));
+ results.emplace_back(Range(l, r));
} else {
auto n = GET_OR_RET(ParseInt<int>(std::string(num_str.begin(),
num_str.end()), minmax)
.Prefixed("an integer is expected in a cron
expression"));
- results.push_back(n);
+ results.emplace_back(n);
}
}
diff --git a/src/config/config_type.h b/src/config/config_type.h
index c11e36943..a1051c110 100644
--- a/src/config/config_type.h
+++ b/src/config/config_type.h
@@ -272,7 +272,7 @@ class IntWithUnitField : public ConfigField {
Status Set(const std::string &v) override { return ReadFrom(v); }
Status ReadFrom(const std::string &val) {
- auto [num, rest] = GET_OR_RET(TryParseInt<T>(val.c_str(), 10));
+ auto [num, rest] = GET_OR_RET(TryParseInt<T>(val, 10));
if (*rest == 0) {
*receiver_ = num;
diff --git a/src/search/hnsw_indexer.cc b/src/search/hnsw_indexer.cc
index de0f519a9..cb9aca770 100644
--- a/src/search/hnsw_indexer.cc
+++ b/src/search/hnsw_indexer.cc
@@ -297,8 +297,8 @@ StatusOr<std::vector<VectorItemWithDistance>>
HnswIndex::SearchLayerInternal(
VectorItem::Create(entry_point_key,
std::move(entry_node_metadata.vector), metadata, &entry_point_vector));
auto dist = GET_OR_RET(ComputeSimilarity(target_vector,
entry_point_vector));
- explore_heap.push(std::make_pair(dist, entry_point_vector));
- result_heap.push(std::make_pair(dist, std::move(entry_point_vector)));
+ explore_heap.emplace(dist, entry_point_vector);
+ result_heap.emplace(dist, std::move(entry_point_vector));
visited.insert(entry_point_key);
}
@@ -326,8 +326,8 @@ StatusOr<std::vector<VectorItemWithDistance>>
HnswIndex::SearchLayerInternal(
&neighbour_node_vector));
auto dist = GET_OR_RET(ComputeSimilarity(target_vector,
neighbour_node_vector));
- explore_heap.push(std::make_pair(dist, neighbour_node_vector));
- result_heap.push(std::make_pair(dist, neighbour_node_vector));
+ explore_heap.emplace(dist, neighbour_node_vector);
+ result_heap.emplace(dist, neighbour_node_vector);
while (result_heap.size() > ef_runtime) {
result_heap.pop();
}
diff --git a/src/types/redis_geo.cc b/src/types/redis_geo.cc
index 2bdac0f5a..c38824724 100644
--- a/src/types/redis_geo.cc
+++ b/src/types/redis_geo.cc
@@ -64,7 +64,7 @@ rocksdb::Status Geo::Hash(engine::Context &ctx, const Slice
&user_key, const std
for (const auto &member : members) {
auto iter = geo_points.find(member.ToString());
if (iter == geo_points.end()) {
- geo_hashes->emplace_back(std::string());
+ geo_hashes->emplace_back();
continue;
}
geo_hashes->emplace_back(EncodeGeoHash(iter->second.longitude,
iter->second.latitude));
diff --git a/x.py b/x.py
index 69681e647..b40577532 100755
--- a/x.py
+++ b/x.py
@@ -30,7 +30,7 @@ from shutil import which
CMAKE_REQUIRE_VERSION = (3, 16, 0)
CLANG_FORMAT_REQUIRED_VERSION = (18, 0, 0)
-CLANG_TIDY_REQUIRED_VERSION = (12, 0, 0)
+CLANG_TIDY_REQUIRED_VERSION = (18, 0, 0)
GOLANGCI_LINT_REQUIRED_VERSION = (2, 5, 0)
SEMVER_REGEX = re.compile(