diff --git a/.github/workflows/pikiwidb.yml b/.github/workflows/pikiwidb.yml index 26e87fa79..5bf4c3256 100644 --- a/.github/workflows/pikiwidb.yml +++ b/.github/workflows/pikiwidb.yml @@ -17,7 +17,7 @@ jobs: - name: Check Format working-directory: ${{ github.workspace }}/build - run: clang-format --version + run: make check-format build_on_macos: runs-on: macos-latest diff --git a/src/cmd_admin.h b/src/cmd_admin.h index 82ac51194..c79c0561e 100644 --- a/src/cmd_admin.h +++ b/src/cmd_admin.h @@ -37,7 +37,7 @@ class CmdConfig : public BaseCmdGroup { private: // std::vector subCmd_; - void DoCmd(PClient* client) override {}; + void DoCmd(PClient* client) override{}; }; class CmdConfigGet : public BaseCmd { @@ -178,7 +178,7 @@ class CmdDebug : public BaseCmdGroup { bool DoInitial(PClient* client) override { return true; }; private: - void DoCmd(PClient* client) override {}; + void DoCmd(PClient* client) override{}; }; class CmdDebugHelp : public BaseCmd { diff --git a/src/net/base_event.h b/src/net/base_event.h index 72368aea9..32d82be1f 100644 --- a/src/net/base_event.h +++ b/src/net/base_event.h @@ -45,7 +45,7 @@ class BaseEvent : public std::enable_shared_from_this { const static int EVENT_HUB; BaseEvent(const std::shared_ptr &listen, int8_t mode, int8_t type) - : listen_(listen), mode_(mode), type_(type) {}; + : listen_(listen), mode_(mode), type_(type){}; virtual ~BaseEvent() = default; diff --git a/src/net/base_socket.h b/src/net/base_socket.h index b12811e11..875ff3154 100644 --- a/src/net/base_socket.h +++ b/src/net/base_socket.h @@ -34,7 +34,7 @@ class BaseSocket : public NetEvent { ~BaseSocket() override = default; - void OnError() override {}; + void OnError() override{}; void Close() override; diff --git a/src/net/callback_function.h b/src/net/callback_function.h index 458e4bba2..57bf086a7 100644 --- a/src/net/callback_function.h +++ b/src/net/callback_function.h @@ -35,7 +35,8 @@ concept HasSetFdFunction = requires(T t, uint64_t id, int8_t index) { { (*t).GetConnId() } -> std::same_as; // GetFd return type is int { (*t).SetThreadIndex(index) } -> std::same_as; // SetThreadIndex return type is void { (*t).GetThreadIndex() } -> std::same_as; // GetThreadIndex return type is int8_t -} || std::is_class_v; // If T is an ordinary class, the member function is called directly +} +|| std::is_class_v; // If T is an ordinary class, the member function is called directly template requires HasSetFdFunction diff --git a/src/net/client_socket.h b/src/net/client_socket.h index 2a3f0d2cf..04916f9f8 100644 --- a/src/net/client_socket.h +++ b/src/net/client_socket.h @@ -13,7 +13,7 @@ namespace net { class ClientSocket : public StreamSocket { public: - explicit ClientSocket(const SocketAddr& addr) : StreamSocket(0, SOCKET_TCP), addr_(addr) {}; + explicit ClientSocket(const SocketAddr& addr) : StreamSocket(0, SOCKET_TCP), addr_(addr){}; ~ClientSocket() override = default; diff --git a/src/net/epoll_event.h b/src/net/epoll_event.h index 529dd99f7..bc00c278c 100644 --- a/src/net/epoll_event.h +++ b/src/net/epoll_event.h @@ -23,7 +23,7 @@ namespace net { class EpollEvent : public BaseEvent { public: explicit EpollEvent(const std::shared_ptr &listen, int8_t mode) - : BaseEvent(listen, mode, BaseEvent::EVENT_TYPE_EPOLL) {}; + : BaseEvent(listen, mode, BaseEvent::EVENT_TYPE_EPOLL){}; ~EpollEvent() override { Close(); } diff --git a/src/net/event_server.h b/src/net/event_server.h index dbaafb5c6..6eafd18cf 100644 --- a/src/net/event_server.h +++ b/src/net/event_server.h @@ -104,8 +104,7 @@ class EventServer final { }; template -requires HasSetFdFunction -std::pair EventServer::StartServer(int64_t interval) { +requires HasSetFdFunction std::pair EventServer::StartServer(int64_t interval) { if (threadNum_ <= 0) { return std::pair(false, "thread num must be greater than 0"); } @@ -144,8 +143,7 @@ std::pair EventServer::StartServer(int64_t interval) { } template -requires HasSetFdFunction -std::pair EventServer::StartClientServer() { +requires HasSetFdFunction std::pair EventServer::StartClientServer() { if (threadNum_ <= 0) { return std::pair(false, "thread num must be greater than 0"); } diff --git a/src/net/io_thread.h b/src/net/io_thread.h index f30655927..0deaefcaf 100644 --- a/src/net/io_thread.h +++ b/src/net/io_thread.h @@ -16,7 +16,7 @@ namespace net { class IOThread { public: - explicit IOThread(const std::shared_ptr &event) : baseEvent_(event) {}; + explicit IOThread(const std::shared_ptr &event) : baseEvent_(event){}; ~IOThread() = default; diff --git a/src/net/kqueue_event.h b/src/net/kqueue_event.h index 086dd01be..0a31be596 100644 --- a/src/net/kqueue_event.h +++ b/src/net/kqueue_event.h @@ -24,7 +24,7 @@ namespace net { class KqueueEvent : public BaseEvent { public: explicit KqueueEvent(std::shared_ptr listen, int8_t mode) - : BaseEvent(std::move(listen), mode, BaseEvent::EVENT_TYPE_KQUEUE) {}; + : BaseEvent(std::move(listen), mode, BaseEvent::EVENT_TYPE_KQUEUE){}; ~KqueueEvent() override { Close(); } diff --git a/src/net/thread_manager.h b/src/net/thread_manager.h index c202ab474..a7c819eda 100644 --- a/src/net/thread_manager.h +++ b/src/net/thread_manager.h @@ -114,10 +114,7 @@ class ThreadManager { }; template -requires HasSetFdFunction -ThreadManager::~ThreadManager() { - Stop(); -} +requires HasSetFdFunction ThreadManager::~ThreadManager() { Stop(); } template requires HasSetFdFunction @@ -204,9 +201,7 @@ void ThreadManager::OnNetEventClose(uint64_t connId, std::string &&err) { template requires HasSetFdFunction -void ThreadManager::CloseConnection(uint64_t connId) { - OnNetEventClose(connId, ""); -} +void ThreadManager::CloseConnection(uint64_t connId) { OnNetEventClose(connId, ""); } template requires HasSetFdFunction @@ -331,8 +326,8 @@ bool ThreadManager::CreateWriteThread() { } template -requires HasSetFdFunction -uint64_t ThreadManager::DoTCPConnect(T &t, int fd, const std::shared_ptr &conn) { +requires HasSetFdFunction uint64_t ThreadManager::DoTCPConnect(T &t, int fd, + const std::shared_ptr &conn) { auto connId = getConnId(); if constexpr (IsPointer_v) { t->SetConnId(connId); diff --git a/src/storage/src/base_data_value_format.h b/src/storage/src/base_data_value_format.h index 26d6a9736..2bb7d7621 100644 --- a/src/storage/src/base_data_value_format.h +++ b/src/storage/src/base_data_value_format.h @@ -97,7 +97,7 @@ class ParsedBaseDataValue : public ParsedInternalValue { } protected: - virtual void SetVersionToValue() override {}; + virtual void SetVersionToValue() override{}; private: const size_t kBaseDataValueSuffixLength = kSuffixReserveLength + kTimestampLength;