This is an automated email from the ASF dual-hosted git repository.
binbin 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 f432e6cf ci: add typos check (#1663)
f432e6cf is described below
commit f432e6cf5b61eed778751677cc71ce56fc94491a
Author: tison <[email protected]>
AuthorDate: Fri Aug 11 15:13:43 2023 +0800
ci: add typos check (#1663)
This PR adds a typo checker CI action that will fail
future PRs if they introduce typos and spelling mistakes.
This supersedes and thus closes #1660.
Signed-off-by: tison <[email protected]>
Co-authored-by: Viktor Szépe <[email protected]>
---
.github/config/typos.toml | 32 ++++++++++++++++++++++++++++++++
.github/workflows/kvrocks.yaml | 18 +++++++++++++++---
kvrocks.conf | 4 ++--
src/cluster/slot_import.cc | 2 +-
src/cluster/slot_migrate.cc | 2 +-
src/commands/cmd_cluster.cc | 4 ++--
src/commands/cmd_server.cc | 14 +++++++-------
src/commands/commander.h | 2 +-
src/commands/error_constants.h | 2 +-
src/types/geohash.cc | 4 ++--
src/types/redis_geo.cc | 2 +-
tests/cppunit/metadata_test.cc | 2 +-
tests/cppunit/types/hash_test.cc | 2 +-
tests/cppunit/types/stream_test.cc | 8 ++++----
tests/gocase/unit/multi/multi_test.go | 2 +-
15 files changed, 72 insertions(+), 28 deletions(-)
diff --git a/.github/config/typos.toml b/.github/config/typos.toml
new file mode 100644
index 00000000..f71dae4f
--- /dev/null
+++ b/.github/config/typos.toml
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[files]
+extend-exclude = [
+ ".git/",
+ "src/common/sha1.cc",
+ "tests/gocase/util/slot.go",
+]
+ignore-hidden = false
+
+[default.extend-words]
+# keywords
+"exat" = "exat"
+"smove" = "smove"
+
+# random strings
+"ue" = "ue"
diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml
index 5d091656..832acc90 100644
--- a/.github/workflows/kvrocks.yaml
+++ b/.github/workflows/kvrocks.yaml
@@ -50,6 +50,18 @@ jobs:
run: |
echo "docs_only=${{ fromJSON(steps.changes.outputs.all_count) ==
fromJSON(steps.changes.outputs.docs_count) &&
fromJSON(steps.changes.outputs.docs_count) > 0 }}" >> $GITHUB_OUTPUT
+ check-typos:
+ name: Check typos
+ runs-on: ubuntu-22.04
+ env:
+ FORCE_COLOR: 1
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install typos
+ run: curl -LsSf
https://github.com/crate-ci/typos/releases/download/v1.16.3/typos-v1.16.3-x86_64-unknown-linux-musl.tar.gz
| tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
+ - name: Run typos check
+ run: typos --config .github/config/typos.toml
+
check-and-lint:
name: Lint and check code
needs: [precondition]
@@ -91,7 +103,7 @@ jobs:
build-and-test:
name: Build and test
- needs: [precondition, check-and-lint]
+ needs: [precondition, check-and-lint, check-typos]
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
strategy:
fail-fast: false
@@ -280,7 +292,7 @@ jobs:
check-docker:
name: Check Docker image
- needs: [precondition, check-and-lint]
+ needs: [precondition, check-and-lint, check-typos]
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
runs-on: ubuntu-20.04
steps:
@@ -299,7 +311,7 @@ jobs:
build-and-test-in-container:
name: Build and test in container
- needs: [precondition, check-and-lint]
+ needs: [precondition, check-and-lint, check-typos]
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
strategy:
fail-fast: false
diff --git a/kvrocks.conf b/kvrocks.conf
index 6e703edc..a6c319d0 100644
--- a/kvrocks.conf
+++ b/kvrocks.conf
@@ -566,7 +566,7 @@ rocksdb.max_open_files 8096
# default is 64MB
rocksdb.write_buffer_size 64
-# Target file size for compaction, target file size for Leve N can be
calculated
+# Target file size for compaction, target file size for Level N can be
calculated
# by target_file_size_base * (target_file_size_multiplier ^ (L-1))
#
# Default: 128MB
@@ -802,7 +802,7 @@ rocksdb.write_options.sync no
# If yes, writes will not first go to the write ahead log,
# and the write may get lost after a crash.
#
-# Deafult: no
+# Default: no
rocksdb.write_options.disable_wal no
# If enabled and we need to wait or sleep for the write request, fails
diff --git a/src/cluster/slot_import.cc b/src/cluster/slot_import.cc
index 363f9559..91d9381a 100644
--- a/src/cluster/slot_import.cc
+++ b/src/cluster/slot_import.cc
@@ -105,7 +105,7 @@ void SlotImport::StopForLinkError(int fd) {
// 2. Source server's migration process end after destination server has
finished replication.
// 3. The migration link closed by source server, then this function will be
call by OnEvent.
// 4. ClearKeysOfSlot can clear data although server is a slave, because
ClearKeysOfSlot
- // deletes data in rocksdb directly. Therefor, it is necessary to avoid
clearing data gotten
+ // deletes data in rocksdb directly. Therefore, it is necessary to avoid
clearing data gotten
// from new master.
if (!svr_->IsSlave()) {
// Clean imported slot data
diff --git a/src/cluster/slot_migrate.cc b/src/cluster/slot_migrate.cc
index fca6b23a..7f08f85a 100644
--- a/src/cluster/slot_migrate.cc
+++ b/src/cluster/slot_migrate.cc
@@ -363,7 +363,7 @@ Status SlotMigrator::sendSnapshot() {
}
LOG(INFO) << "[migrate] Succeed to migrate slot snapshot, slot: " << slot <<
", Migrated keys: " << migrated_key_cnt
- << ", Expired keys: " << expired_key_cnt << ", Emtpy keys: " <<
empty_key_cnt;
+ << ", Expired keys: " << expired_key_cnt << ", Empty keys: " <<
empty_key_cnt;
return Status::OK();
}
diff --git a/src/commands/cmd_cluster.cc b/src/commands/cmd_cluster.cc
index b7882251..03e3bee8 100644
--- a/src/commands/cmd_cluster.cc
+++ b/src/commands/cmd_cluster.cc
@@ -56,7 +56,7 @@ class CommandCluster : public Commander {
}
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
if (subcommand_ == "keyslot") {
@@ -216,7 +216,7 @@ class CommandClusterX : public Commander {
}
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
bool need_persist_nodes_info = false;
diff --git a/src/commands/cmd_server.cc b/src/commands/cmd_server.cc
index d3c6b9cf..e8545c49 100644
--- a/src/commands/cmd_server.cc
+++ b/src/commands/cmd_server.cc
@@ -82,7 +82,7 @@ class CommandNamespace : public Commander {
public:
Status Execute(Server *svr, Connection *conn, std::string *output) override {
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
Config *config = svr->GetConfig();
@@ -173,7 +173,7 @@ class CommandFlushAll : public Commander {
public:
Status Execute(Server *svr, Connection *conn, std::string *output) override {
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
if (svr->GetConfig()->cluster_enabled) {
@@ -221,7 +221,7 @@ class CommandConfig : public Commander {
public:
Status Execute(Server *svr, Connection *conn, std::string *output) override {
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
Config *config = svr->GetConfig();
@@ -547,7 +547,7 @@ class CommandShutdown : public Commander {
public:
Status Execute(Server *srv, Connection *conn, std::string *output) override {
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
if (!srv->IsStopped()) {
@@ -842,7 +842,7 @@ class CommandBGSave : public Commander {
public:
Status Execute(Server *svr, Connection *conn, std::string *output) override {
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
Status s = svr->AsyncBgSaveDB();
@@ -858,7 +858,7 @@ class CommandFlushBackup : public Commander {
public:
Status Execute(Server *svr, Connection *conn, std::string *output) override {
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
Status s = svr->AsyncPurgeOldBackups(0, 0);
@@ -917,7 +917,7 @@ class CommandSlaveOf : public Commander {
}
if (!conn->IsAdmin()) {
- return {Status::RedisExecErr, errAdministorPermissionRequired};
+ return {Status::RedisExecErr, errAdminPermissionRequired};
}
if (host_.empty()) {
diff --git a/src/commands/commander.h b/src/commands/commander.h
index 0bf6448d..11329f72 100644
--- a/src/commands/commander.h
+++ b/src/commands/commander.h
@@ -126,7 +126,7 @@ struct CommandAttributes {
// negative number -n means number of arguments is equal to or large than n
int arity;
- // space-splitted flag strings to initialize flags
+ // space-separated flag strings to initialize flags
std::string description;
// bitmap of enum CommandFlags
diff --git a/src/commands/error_constants.h b/src/commands/error_constants.h
index 6311c2b7..b9c05ed5 100644
--- a/src/commands/error_constants.h
+++ b/src/commands/error_constants.h
@@ -26,7 +26,7 @@ inline constexpr const char *errInvalidSyntax = "syntax
error";
inline constexpr const char *errInvalidExpireTime = "invalid expire time";
inline constexpr const char *errWrongNumOfArguments = "wrong number of
arguments";
inline constexpr const char *errValueNotInteger = "value is not an integer or
out of range";
-inline constexpr const char *errAdministorPermissionRequired = "administor
permission required to perform the command";
+inline constexpr const char *errAdminPermissionRequired = "admin permission
required to perform the command";
inline constexpr const char *errValueMustBePositive = "value is out of range,
must be positive";
inline constexpr const char *errNoSuchKey = "no such key";
inline constexpr const char *errUnbalancedStreamList =
diff --git a/src/types/geohash.cc b/src/types/geohash.cc
index 120868f6..1bbcecee 100644
--- a/src/types/geohash.cc
+++ b/src/types/geohash.cc
@@ -312,7 +312,7 @@ uint8_t GeoHashHelper::EstimateStepsByRadius(double
range_meters, double lat) {
}
step -= 2; /* Make sure range is included in most of the base cases. */
- /* Wider range torwards the poles... Note: it is possible to do better
+ /* Wider range towards the poles... Note: it is possible to do better
* than this approximation by computing the distance between meridians
* at this latitude, but this does the trick for now. */
if (lat > 66 || lat < -66) {
@@ -328,7 +328,7 @@ uint8_t GeoHashHelper::EstimateStepsByRadius(double
range_meters, double lat) {
/* Return the bounding box of the search area centered at latitude,longitude
* having a radius of radius_meter. bounds[0] - bounds[2] is the minimum
- * and maxium longitude, while bounds[1] - bounds[3] is the minimum and
+ * and maximum longitude, while bounds[1] - bounds[3] is the minimum and
* maximum latitude. */
int GeoHashHelper::BoundingBox(GeoShape *geo_shape) {
if (!geo_shape->bounds) return 0;
diff --git a/src/types/redis_geo.cc b/src/types/redis_geo.cc
index a7deafb8..d5e1c78b 100644
--- a/src/types/redis_geo.cc
+++ b/src/types/redis_geo.cc
@@ -320,7 +320,7 @@ void Geo::scoresOfGeoHashBox(GeoHashBits hash,
GeoHashFix52Bits *min, GeoHashFix
* 'max', appending them into the array of GeoPoint structures 'gparray'.
* The command returns the number of elements added to the array.
*
- * Elements which are farest than 'radius' from the specified 'x' and 'y'
+ * Elements which are farthest than 'radius' from the specified 'x' and 'y'
* coordinates are not included.
*
* The ability of this function to append to an existing set of points is
diff --git a/tests/cppunit/metadata_test.cc b/tests/cppunit/metadata_test.cc
index a96a6dd6..a463bc20 100644
--- a/tests/cppunit/metadata_test.cc
+++ b/tests/cppunit/metadata_test.cc
@@ -45,7 +45,7 @@ TEST(InternalKey, EncodeAndDecode) {
EXPECT_EQ(ikey, ikey1);
}
-TEST(Metadata, EncodeAndDeocde) {
+TEST(Metadata, EncodeAndDecode) {
std::string string_bytes;
Metadata string_md(kRedisString);
string_md.expire = 123000;
diff --git a/tests/cppunit/types/hash_test.cc b/tests/cppunit/types/hash_test.cc
index 216acc72..51621e84 100644
--- a/tests/cppunit/types/hash_test.cc
+++ b/tests/cppunit/types/hash_test.cc
@@ -303,7 +303,7 @@ TEST_F(RedisHashTest, HRangeByLex) {
EXPECT_EQ("key1", result[0].field);
EXPECT_EQ("key2", result[1].field);
- // inf and revered
+ // inf and reversed
spec.minex = false;
spec.maxex = false;
spec.min = "-";
diff --git a/tests/cppunit/types/stream_test.cc
b/tests/cppunit/types/stream_test.cc
index 42607e6e..9ed7bb33 100644
--- a/tests/cppunit/types/stream_test.cc
+++ b/tests/cppunit/types/stream_test.cc
@@ -718,7 +718,7 @@ TEST_F(RedisStreamTest, RangeWithStartAndEndAreEqual) {
CheckStreamEntryValues(entries[0].values, values2);
}
-TEST_F(RedisStreamTest, RangeWithStartAndEndAreEqualAndExludedStart) {
+TEST_F(RedisStreamTest, RangeWithStartAndEndAreEqualAndExcludedStart) {
redis::StreamAddOptions add_options;
add_options.next_id_strategy =
*ParseNextStreamEntryIDStrategy(fmt::format("{}-{}", 123456, 1));
std::vector<std::string> values1 = {"key1", "val1"};
@@ -741,7 +741,7 @@ TEST_F(RedisStreamTest,
RangeWithStartAndEndAreEqualAndExludedStart) {
EXPECT_EQ(entries.size(), 0);
}
-TEST_F(RedisStreamTest, RangeWithStartAndEndAreEqualAndExludedEnd) {
+TEST_F(RedisStreamTest, RangeWithStartAndEndAreEqualAndExcludedEnd) {
redis::StreamAddOptions add_options;
add_options.next_id_strategy =
*ParseNextStreamEntryIDStrategy(fmt::format("{}-{}", 123456, 1));
std::vector<std::string> values1 = {"key1", "val1"};
@@ -876,7 +876,7 @@ TEST_F(RedisStreamTest,
RangeWithExcludedStartAndExcludedEnd) {
CheckStreamEntryValues(entries[1].values, values3);
}
-TEST_F(RedisStreamTest, RangeWithStartAsMaximumAndExlusion) {
+TEST_F(RedisStreamTest, RangeWithStartAsMaximumAndExclusion) {
redis::StreamAddOptions add_options;
add_options.next_id_strategy =
*ParseNextStreamEntryIDStrategy(fmt::format("{}-{}", 123456, 1));
std::vector<std::string> values1 = {"key1", "val1"};
@@ -893,7 +893,7 @@ TEST_F(RedisStreamTest, RangeWithStartAsMaximumAndExlusion)
{
EXPECT_TRUE(!s.ok());
}
-TEST_F(RedisStreamTest, RangeWithEndAsMinimumAndExlusion) {
+TEST_F(RedisStreamTest, RangeWithEndAsMinimumAndExclusion) {
redis::StreamAddOptions add_options;
add_options.next_id_strategy =
*ParseNextStreamEntryIDStrategy(fmt::format("{}-{}", 123456, 1));
std::vector<std::string> values1 = {"key1", "val1"};
diff --git a/tests/gocase/unit/multi/multi_test.go
b/tests/gocase/unit/multi/multi_test.go
index b2de3780..c2a96917 100644
--- a/tests/gocase/unit/multi/multi_test.go
+++ b/tests/gocase/unit/multi/multi_test.go
@@ -37,7 +37,7 @@ func TestMulti(t *testing.T) {
rdb := srv.NewClient()
defer func() { require.NoError(t, rdb.Close()) }()
- t.Run("MUTLI / EXEC basics", func(t *testing.T) {
+ t.Run("MULTI / EXEC basics", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "mylist").Err())
require.NoError(t, rdb.RPush(ctx, "mylist", "a").Err())
require.NoError(t, rdb.RPush(ctx, "mylist", "b").Err())