style: Remove redundant trailing semicolons and sync lint flags#17
style: Remove redundant trailing semicolons and sync lint flags#17
Conversation
- 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
Walkthrough本 PR 更新了 linting 基础设施,使其能从项目结构中的 .clangd 文件收集 clang-tidy 参数,重构 LintTarget 使用 project_dir 作为主要引用,并清理多个 C++ 文件中函数定义后多余的分号。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.scripts/clang-tidy-check (1)
121-159:collect_clangd_extra_args实现合理,层级遍历逻辑正确。从
root到project_dir逐级收集.clangd文件中的CompileFlags.Add,错误处理也到位(YAML 解析异常、非预期类型等)。去重使用seen_flags集合也是正确的做法。有一个小建议:当
project_dir在root之外时(ValueError分支),可以考虑输出一条stderr警告,便于调试配置错误。当前静默返回[]在调用方不易察觉。
概述
本PR进行了样式和代码检查工具配置的统一更新。主要包括:添加-Wextra-semi编译警告标志、重构clang-tidy配置继承机制,以及移除整个代码库中C++成员函数定义后的冗余尾部分号。
配置和工具更新
.clangd编译标志增强
-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数据模型重构
.scripts/lint-targets.yml配置更新
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方法代码审查要点