Skip to content

Comments

style: Remove redundant trailing semicolons and sync lint flags#17

Merged
qzhhhi merged 1 commit intomainfrom
dev/fix-semi
Feb 16, 2026
Merged

style: Remove redundant trailing semicolons and sync lint flags#17
qzhhhi merged 1 commit intomainfrom
dev/fix-semi

Conversation

@qzhhhi
Copy link
Member

@qzhhhi qzhhhi commented Feb 16, 2026

  • Add -Wextra-semi to default clangd compile flags
  • Make clang-tidy inherit CompileFlags.Add from nested .clangd files
  • Remove redundant trailing semicolons in C++ constructors, destructors, and callbacks

概述

本PR进行了样式和代码检查工具配置的统一更新。主要包括:添加-Wextra-semi编译警告标志、重构clang-tidy配置继承机制,以及移除整个代码库中C++成员函数定义后的冗余尾部分号。

配置和工具更新

.clangd编译标志增强

  • 在CompileFlags.Add中新增-Wextra-semi标志,用于检测不必要的分号

.scripts/clang-tidy-check脚本重构

  • 新增功能collect_clangd_extra_args(project_dir, root)函数,用于从项目根目录向上递归搜索所有.clangd文件,提取CompileFlags.Add条目,去重后返回标志列表
  • 函数移除parse_clangd(target)函数被新的collect_clangd_extra_args替代,实现了更广泛的搜索范围
  • 签名更新
    • clang_tidy_args现接收编译数据库路径、项目目录、根目录和修复标志,并自动追加从.clangd文件收集的额外参数
    • run_clang_tidy新增root参数,用于正确调用更新后的clang_tidy_args

.scripts/lint_common.py数据模型重构

  • LintTarget类重新设计
    • 移除compile_database和clangd字段
    • 新增project_dir字段作为构建配置的根路径
    • 新增compile_database属性,自动计算为project_dir/build/compile_commands.json
  • 加载逻辑更新:load_targets函数现从cmake字段的父目录推导project_dir,而非直接使用compile_database和clangd路径

.scripts/lint-targets.yml配置更新

  • 将编译系统配置从legacy的compile_database和clangd引用改为显式CMakeLists.txt路径
  • 对host和rmcs_board目标进行了相应调整

C++代码风格修正

移除多个文件中类成员函数定义后的冗余尾部分号(函数体后的};变为}):

  • core/src/protocol/deserializer.hpp:Deserializer构造函数
  • firmware/rmcs_board/src/uart/rx_buffer.hpp:RxBuffer构造函数
  • firmware/rmcs_board/src/usb/vendor.hpp:五个回调函数(can_deserialized_callback、uart_deserialized_callback、accelerometer_deserialized_callback、gyroscope_deserialized_callback、error_callback)
  • firmware/rmcs_board/src/utility/lazy.hpp:Lazy类析构函数
  • host/src/protocol/stream_buffer.hpp:构造函数、移动构造函数和析构函数
  • host/src/transport/usb.cpp:acquire_transmit_buffer和receive函数
  • host/src/utility/final_action.hpp:disable方法

代码审查要点

  • 新的clang-tidy配置收集机制在多层级.clangd配置中的正确性验证
  • LintTarget数据模型变更对现有脚本的兼容性确认
  • 分号移除变更对代码编译和语义的无影响性确认

- Add -Wextra-semi to default clangd compile flags
- Make clang-tidy inherit CompileFlags.Add from nested .clangd files
- Remove redundant trailing semicolons in C++ constructors, destructors, and callbacks
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

Walkthrough

本 PR 更新了 linting 基础设施,使其能从项目结构中的 .clangd 文件收集 clang-tidy 参数,重构 LintTarget 使用 project_dir 作为主要引用,并清理多个 C++ 文件中函数定义后多余的分号。

Changes

Cohort / File(s) Summary
Linting Configuration & Compilation Settings
.clangd
添加 -Wextra-semi 编译标志至 CompileFlags.Add 配置。
Linting Script Refactoring
.scripts/clang-tidy-check
引入 collect_clangd_extra_args() 函数遍历项目层级收集 .clangd 中的编译标志;移除 parse_clangd();更新 clang_tidy_args()run_clang_tidy() 函数签名以支持根路径传递和多源标志收集。
Lint Target Configuration
.scripts/lint-targets.yml
将 host 和 rmcs_board lint target 从 compile_database 引用改为显式 CMakeLists.txt 路径。
Lint Target Data Structure
.scripts/lint_common.py
重构 LintTarget:用 project_dir 字段替代 compile_databaseclangd;添加 compile_database 属性维持向后兼容性;更新 load_targets() 从 cmake 路径派生 project_dir。
C++ Syntax Cleanup
core/src/protocol/deserializer.hpp, firmware/rmcs_board/src/uart/rx_buffer.hpp, firmware/rmcs_board/src/usb/vendor.hpp, firmware/rmcs_board/src/utility/lazy.hpp, host/src/protocol/stream_buffer.hpp, host/src/transport/usb.cpp, host/src/utility/final_action.hpp
移除 C++ 内联函数定义结束处的多余分号,与 -Wextra-semi 警告保持一致。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨ 一只聪慧的兔子,
清理了古老的分号,
在编译标志中翩翩起舞,
cmake 的路径更清晰,
lint 工具重获新生!🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (11 files):

⚔️ .clangd (content)
⚔️ .scripts/clang-tidy-check (content)
⚔️ .scripts/lint-targets.yml (content)
⚔️ .scripts/lint_common.py (content)
⚔️ core/src/protocol/deserializer.hpp (content)
⚔️ firmware/rmcs_board/src/uart/rx_buffer.hpp (content)
⚔️ firmware/rmcs_board/src/usb/vendor.hpp (content)
⚔️ firmware/rmcs_board/src/utility/lazy.hpp (content)
⚔️ host/src/protocol/stream_buffer.hpp (content)
⚔️ host/src/transport/usb.cpp (content)
⚔️ host/src/utility/final_action.hpp (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:删除冗余的尾部分号和同步代码检查标志。涵盖了两个核心改动方向。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev/fix-semi
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch dev/fix-semi
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.scripts/clang-tidy-check (1)

121-159: collect_clangd_extra_args 实现合理,层级遍历逻辑正确。

rootproject_dir 逐级收集 .clangd 文件中的 CompileFlags.Add,错误处理也到位(YAML 解析异常、非预期类型等)。去重使用 seen_flags 集合也是正确的做法。

有一个小建议:当 project_dirroot 之外时(ValueError 分支),可以考虑输出一条 stderr 警告,便于调试配置错误。当前静默返回 [] 在调用方不易察觉。

@qzhhhi qzhhhi merged commit 48a355f into main Feb 16, 2026
5 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in RMCS Slave SDK Feb 16, 2026
@qzhhhi qzhhhi deleted the dev/fix-semi branch February 16, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant