Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes checkLocalFolder so it validates the path supplied by its caller and removes a no-op QRect mutation from CmdButtonWidget::paintEvent; rendering and current-call behavior should remain unchanged. Sequence diagram for validating the caller-provided folder pathsequenceDiagram
participant Caller
participant UrlChooserEdit
participant QStorageInfo
Caller->>UrlChooserEdit: checkLocalFolder(path)
UrlChooserEdit->>QStorageInfo: QStorageInfo(path)
QStorageInfo-->>UrlChooserEdit: isValid() and device()
alt local valid folder
UrlChooserEdit->>UrlChooserEdit: setAlert(false)
else non-local or invalid path
UrlChooserEdit->>UrlChooserEdit: setAlert(true)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: checkLocalFolder(const QString &path) discarded the parameter via Q_UNUSED(path) and used member mp_folderPath instead, making the API misleading; CmdButtonWidget::paintEvent called this->rect().setWidth(808) on a temporary QRect copy, which is dead code since the next line achieves the intent correctly 2. Fix: remove Q_UNUSED(path) and use the path parameter in QStorageInfo constructor; remove the dead code line in paintEvent; update UT_UrlChooserEdit_checkLocalFolder_001 to pass smb:// path matching mp_folderPath so the test validates fixed behavior 3. Impact: checkLocalFolder now validates the actual parameter passed by the caller; paintEvent behavior unchanged since the dead line had no effect; test case now correctly expects alert for non-local path; current callers pass the same value so no behavior change Influence: 1. Test checkLocalFolder with a local valid folder path 2. Test checkLocalFolder with a non-local or invalid path 3. Verify CmdButtonWidget paint rendering is unchanged fix: 修复checkLocalFolder忽略形参及更新测试用例 1. 根因:checkLocalFolder(const QString &path) 通过 Q_UNUSED(path) 丢弃形参,实际使用成员 mp_folderPath,导致 API 语义误导; CmdButtonWidget::paintEvent 中 this->rect().setWidth(808) 对 临时 QRect 副本调用,属于死代码,下一行已正确实现相同逻辑 2. 方案:移除 Q_UNUSED(path),将 QStorageInfo info(mp_folderPath) 改为 QStorageInfo info(path);移除 paintEvent 中的死代码行; 更新 UT_UrlChooserEdit_checkLocalFolder_001 传入 smb:// 路径 与 mp_folderPath 一致,使测试验证修复后的正确行为 3. 影响:checkLocalFolder 现在校验实际传入的形参;paintEvent 行为 不变(死代码行本就无效果);测试用例现在正确期望非本地路径 触发告警;当前调用点传入值与成员相同,实际无行为变化 Influence: 1. 测试 checkLocalFolder 传入本地有效文件夹路径 2. 测试 checkLocalFolder 传入非本地或无效路径 3. 验证 CmdButtonWidget 绘制效果无变化 Fixes: linuxdeepin#936 PMS: BUG-bug-fix-936-1
ba9191d to
84a7f45
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ❌评价: 存在逻辑缺陷 ❌ 不通过 潜在问题: 建议: ['修改测试用例,使 mp_folderPath 和 path 参数使用不同的值。例如设置 mp_folderPath 为本地路径 "/home",传入非本地路径 "smb://10.4.10.4" 作为参数, 这样如果函数错误地使用 mp_folderPath,isAlert 将为 false,测试会失败'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 改进后的测试用例,使用不同的值来真正验证修复效果
TEST_F(UT_UrlChooserEdit, UT_UrlChooserEdit_checkLocalFolder_001)
{
// 设置 mp_folderPath 为本地路径,传入非本地路径作为参数
// 如果 checkLocalFolder 错误地使用 mp_folderPath,isAlert 将为 false,测试会失败
m_UrlChooserEdit->mp_folderPath = "/home";
m_UrlChooserEdit->checkLocalFolder("smb://10.4.10.4");
EXPECT_TRUE(m_UrlChooserEdit->mp_urlEdit->isAlert());
// 反向测试:传入本地路径作为参数,不应触发 alert
m_UrlChooserEdit->mp_folderPath = "smb://10.4.10.4";
m_UrlChooserEdit->checkLocalFolder("/home");
EXPECT_FALSE(m_UrlChooserEdit->mp_urlEdit->isAlert());
}本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.0.75 |
fix: fix checkLocalFolder ignoring param and remove dead code
parameter via Q_UNUSED(path) and used member mp_folderPath instead,
making the API misleading; CmdButtonWidget::paintEvent called
this->rect().setWidth(808) on a temporary QRect copy, which is
dead code since the next line achieves the intent correctly
QStorageInfo constructor; remove the dead code line in paintEvent
by the caller; paintEvent behavior unchanged since the dead line
had no effect; current callers pass the same value so no behavior
change in practice
Influence:
fix: 修复checkLocalFolder忽略形参及移除paintEvent死代码
丢弃形参,实际使用成员 mp_folderPath,导致 API 语义误导;
CmdButtonWidget::paintEvent 中 this->rect().setWidth(808) 对
临时 QRect 副本调用,属于死代码,下一行已正确实现相同逻辑
改为 QStorageInfo info(path);移除 paintEvent 中的死代码行
不变(死代码行本就无效果);当前调用点传入值与成员相同,实际
无行为变化
Influence:
Fixes: #936
PMS: BUG-bug-fix-936-1
Summary by Sourcery
Correct local-folder validation semantics and remove ineffective painting code.
Bug Fixes:
Enhancements:
Tests: