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: add typos check #1663

Merged
merged 7 commits into from
Aug 11, 2023
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
32 changes: 32 additions & 0 deletions .github/config/typos.toml
Original file line number Diff line number Diff line change
@@ -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"
18 changes: 15 additions & 3 deletions .github/workflows/kvrocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions kvrocks.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/slot_import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/slot_migrate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/cmd_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CommandCluster : public Commander {
}

if (!conn->IsAdmin()) {
return {Status::RedisExecErr, errAdministorPermissionRequired};
return {Status::RedisExecErr, errAdminPermissionRequired};
}

if (subcommand_ == "keyslot") {
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/commands/cmd_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -917,7 +917,7 @@ class CommandSlaveOf : public Commander {
}

if (!conn->IsAdmin()) {
return {Status::RedisExecErr, errAdministorPermissionRequired};
return {Status::RedisExecErr, errAdminPermissionRequired};
}

if (host_.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/commands/error_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions src/types/geohash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/types/redis_geo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/cppunit/metadata_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/cppunit/types/hash_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "-";
Expand Down
8 changes: 4 additions & 4 deletions tests/cppunit/types/stream_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand All @@ -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"};
Expand Down Expand Up @@ -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"};
Expand All @@ -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"};
Expand Down
2 changes: 1 addition & 1 deletion tests/gocase/unit/multi/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down