Phase 1 - Plugin code review (14/14 plugins): - Security: 3x token leak in print→logger.debug, Bearer prefix handling - Bug: bare except→specific exceptions, HorseState type safety, sync→async - Critical: response_model undefined, route dead code, sync blocking event loop - Quality: 11x print()→logger, variable name shadowing, consistent logging Phase 2 - Deep analysis: - Fix: payout int truncation→max(1, round(amount*odds)) - Fix: room_store get_lock race condition→dict.setdefault() - Verify: data_manager f-string SQL is safe (uses ? placeholders) Infrastructure: review reports generated for all plugins.
2.4 KiB
2.4 KiB
Danding-Bot 插件代码评审报告 - Round 1
日期: 2026-05-09 评审人: Agent 进度: 2/13 插件已完成
1. auto_friend_accept ✅ 已完成
发现问题 (4项)
| # | 严重度 | 问题 | 文件 | 行号 |
|---|---|---|---|---|
| 1 | 低 | 导入validator但未使用 |
config.py | 1 |
| 2 | 中 | Optional[str] = ""语义不清,None和空串应区分 |
config.py | 9 |
| 3 | 低 | 导入T_State但未使用 |
auto_accept.py | 3 |
| 4 | 高 | 嵌套try-except,缩进深,违反篇幅分布原则 | auto_accept.py | 23-48 |
| 5 | 中 | 随机延迟硬编码(2-5s),应可配置 | auto_accept.py | 35 |
| 6 | 中 | 日志缺少flag标识,出问题难追溯 | auto_accept.py | 全局 |
修复项
- 移除未使用的
validator导入 auto_reply_message默认值改为None- 新增
reply_delay_min/max配置项 - 移除未使用的
T_State导入 - 消除嵌套try-except,扁平化控制流
- 日志加入
user_id和flag标识
待改进
- 无明显待改进项
2. auto_recall ✅ 已完成
发现问题 (6项)
| # | 严重度 | 问题 | 文件 | 行号 |
|---|---|---|---|---|
| 1 | 中 | Bot重复导入(line 4和7覆盖) |
init.py | 4,7 |
| 2 | 低 | T_State导入未使用 |
init.py | 8 |
| 3 | 低 | get_driver导入未使用 |
init.py | 3 |
| 4 | 高 | asyncio.create_task未保存引用,可能被GC回收触发RuntimeWarning |
init.py | 48 |
| 5 | 高 | 撤回失败用"success" in str(e).lower()判断忽略,极其脆弱 |
init.py | 56 |
| 6 | 低 | 未拦截send_private_msg,私聊消息不会撤回 |
init.py | 26 |
| 7 | 低 | 配置无边界校验(延迟可为负数) | config.py | 4-5 |
修复项
- 移除重复/未使用的导入(Bot/T_State/get_driver/MockApiException)
- 新增
_recall_tasks集合+_track_task()防止task被GC回收 - 移除脆弱的字符串匹配错误忽略逻辑,统一记录错误
- API拦截列表加入
send_private_msg - config添加
ge=1约束和validator - 日志加入
msg_id便于追溯
待改进
- 可考虑撤回失败时的重试机制(但当前简单记录已足够)
跨插件一致性观察
- 两个插件配置类风格已统一:均为
BaseModel子类 - 日志格式趋于统一:
操作描述: 关键标识=value error={e} - 待后续全局检查时进一步统一