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

fix: fix ci check format failed #443

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

hahahashen
Copy link
Contributor

@hahahashen hahahashen commented Oct 31, 2024

修复因clang format版本不一致导致的format code不同的问题

Summary by CodeRabbit

  • Bug Fixes

    • 更新了多个类中方法的格式,确保语法一致性,未影响功能。
  • Chores

    • 修改了工作流配置,更新了代码格式检查步骤,提升了格式验证的准确性。

Copy link

coderabbitai bot commented Oct 31, 2024

Walkthrough

本次更改涉及多个文件的格式化调整,主要集中在方法声明和构造函数的语法上。具体而言,多个类的方法实现中去掉了大括号前的空格,构造函数的初始化列表末尾的分号被替换为大括号。工作流配置文件也进行了更新,将格式检查步骤的命令从 clang-format --version 更改为 make check-format。整体上,这些更改主要是为了统一代码风格,而未涉及功能性修改。

Changes

文件路径 更改摘要
.github/workflows/pikiwidb.yml 更新格式检查步骤命令,从 clang-format --version 改为 make check-format
src/cmd_admin.h DoCmd 方法实现中去掉了空格,格式更新为 override{}
src/net/base_event.h 构造函数初始化列表末尾的分号替换为大括号,更新为 BaseEvent(listen, mode, type){};
src/net/base_socket.h OnError 方法实现中去掉了空格,更新为 void OnError() override{}
src/net/callback_function.h HasSetFdFunction 概念定义中在逻辑或运算符前增加了换行。
src/net/client_socket.h 构造函数实现中将分号替换为大括号,更新为 ClientSocket(){};
src/net/epoll_event.h 构造函数初始化列表末尾的分号替换为大括号,更新为 BaseEvent(listen, mode, BaseEvent::EVENT_TYPE_EPOLL){}
src/net/event_server.h StartServerStartClientServer 方法的 requires 子句移动到方法签名的同一行。
src/net/io_thread.h 构造函数实现中去掉了分号,更新为 IOThread(const std::shared_ptr<BaseEvent> &event){};
src/net/kqueue_event.h 构造函数初始化列表末尾的分号替换为大括号,未改变构造函数的功能。
src/net/thread_manager.h 更新多个方法和析构函数的 requires 子句位置,确保与方法定义在同一行。
src/storage/src/base_data_value_format.h SetVersionToValue 方法声明中去掉了空格,更新为 virtual void SetVersionToValue() override {}

Possibly related PRs

  • feat: add root dir etc for misc #381: .github/workflows/pikiwidb.yml 文件中的脚本路径更改与主 PR 的修改相关,表明对构建过程的组织和可维护性有关注。
  • fix: pttl cmd error #433: src/cmd_keys.cc 中的 DoCmd 函数修改涉及方法格式化的更改,与主 PR 的代码格式化更改一致,尽管上下文不同。

Suggested labels

🧹 Updates

Poem

在代码的世界里跳跃,
格式的美丽如花绽放,
大括号与空格的舞蹈,
让每行代码都闪亮,
兔子欢呼,代码更新,
让我们一起欢庆这变化! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6352471 and cd62d59.

📒 Files selected for processing (12)
  • .github/workflows/pikiwidb.yml (1 hunks)
  • src/cmd_admin.h (2 hunks)
  • src/net/base_event.h (1 hunks)
  • src/net/base_socket.h (1 hunks)
  • src/net/callback_function.h (1 hunks)
  • src/net/client_socket.h (1 hunks)
  • src/net/epoll_event.h (1 hunks)
  • src/net/event_server.h (2 hunks)
  • src/net/io_thread.h (1 hunks)
  • src/net/kqueue_event.h (1 hunks)
  • src/net/thread_manager.h (3 hunks)
  • src/storage/src/base_data_value_format.h (1 hunks)
✅ Files skipped from review due to trivial changes (9)
  • src/cmd_admin.h
  • src/net/base_event.h
  • src/net/base_socket.h
  • src/net/callback_function.h
  • src/net/client_socket.h
  • src/net/epoll_event.h
  • src/net/io_thread.h
  • src/net/kqueue_event.h
  • src/storage/src/base_data_value_format.h
🔇 Additional comments (6)
.github/workflows/pikiwidb.yml (1)

20-20: 使用 make check-format 是更好的格式检查方式

将格式检查命令更改为 make check-format 是一个很好的改进,它可以通过 Makefile 提供更完整的格式检查流程。

让我们验证一下这个 make 目标是否正确配置:

✅ Verification successful

格式检查配置已正确设置

根据代码库分析,格式检查配置已正确设置:

  1. CMakeLists.txt 中定义了 check-format 目标,使用 run_clang_format.py 脚本执行检查
  2. 存在 .clang-format 配置文件,基于 Google 风格定义了详细的代码格式规则
  3. build_support/run_clang_format.py 脚本实现了格式检查的具体逻辑

make check-format 命令将正确执行以下操作:

  • 使用项目的 .clang-format 配置
  • 检查 src/ 目录下的所有源文件
  • 排除特定的忽略文件
  • 报告任何格式不符合规范的问题
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证 check-format 目标在 CMake 构建系统中是否正确配置

# 测试:检查 CMakeLists.txt 文件中是否定义了 check-format 目标
rg -l "add_custom_target.*check-format" 

# 测试:检查是否有相关的格式化配置文件
fd -t f ".clang-format$"

Length of output: 68


Script:

#!/bin/bash
# 检查 Makefile 中是否定义了 check-format 目标
fd -t f "Makefile$|\.mk$" --exec cat {}

# 检查是否有其他格式化相关的文件
fd -t f "format|fmt|style" --exec echo "=== {} ===" \; --exec cat {}

Length of output: 53807


Script:

#!/bin/bash
# 检查 CMakeLists.txt 中的格式化相关配置
fd -t f "CMakeLists.txt$" --exec cat {}

# 检查是否有 .clang-format 配置文件
find . -maxdepth 1 -name ".clang-format" -type f -exec cat {} \;

# 检查 Makefile 中的格式化目标
find . -maxdepth 1 -name "Makefile" -type f -exec cat {} \;

Length of output: 24663

src/net/event_server.h (2)

107-107: 格式调整符合预期

代码格式调整将 requires 约束移至方法签名同一行,这样的改动使代码格式更加统一,有助于提高可读性。


146-146: 格式变更保持一致性

StartServer 方法的格式调整保持一致,将 requires 约束移至方法签名同一行,维持了整个类中格式的统一性。

src/net/thread_manager.h (3)

117-117: 析构函数格式调整符合预期

格式调整将 requires 子句移至同一行,使代码更加紧凑,同时保持了功能的完整性。这个改动与 PR 的目标(修复 CI 格式检查)保持一致。


204-204: CloseConnection 方法格式调整合理

requires 子句移至方法声明同一行的格式调整,保持了与其他方法的一致性,有助于提高代码的可读性。


329-330: DoTCPConnect 方法的格式调整恰当

函数签名的格式调整合理,包括:

  1. requires 子句移至同一行
  2. 参数列表的换行缩进调整

这些改动使代码格式更加规范,符合项目的代码风格要求。


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Oct 31, 2024
@chejinge chejinge merged commit 1149766 into OpenAtomFoundation:unstable Oct 31, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️ Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants