Skip to content

feat: add directory exclusion feature to search#346

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Johnson-zs:master
Jul 13, 2026
Merged

feat: add directory exclusion feature to search#346
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Johnson-zs:master

Conversation

@Johnson-zs

Copy link
Copy Markdown
Contributor

Added support for excluding specific directories from search results
via new --exclude parameter. Users can now provide comma-separated paths
to skip during searching. This improves search performance by avoiding
unnecessary directories like /tmp or .cache folders.

The implementation includes:

  1. New CLI option --exclude in dfm-searcher
  2. SemanticSearcher API extension for excluded paths
  3. Integration with underlying search engines
  4. Documentation updates with examples
  5. Backward compatible with older Qt versions

Log: Added --exclude option to skip specified directories during search

Influence:

  1. Test exclusion with various path formats (absolute, relative, with
    spaces)
  2. Verify search performance in directories containing excluded paths
  3. Check semantic search exclusion behavior
  4. Test combinations with other filters (time, size)
  5. Verify JSON output includes excluded paths information

feat: 新增搜索目录排除功能

新增通过--exclude参数排除特定目录的功能。用户可通过逗号分隔的路径列表跳
过特定目录搜索,提高搜索性能(特别是跳过/tmp或.cache等无关目录)

实现包括:

  1. dfm-searcher新增--exclude命令行选项
  2. 扩展SemanticSearcher API支持排除路径
  3. 底层搜索引擎集成
  4. 文档更新并添加示例
  5. 保持对旧版Qt的兼容性

Log: 新增--exclude选项可跳过指定目录的搜索

Influence:

  1. 测试不同路径格式的排除功能(绝对路径、相对路径、含空格路径)
  2. 验证包含排除路径的目录中的搜索性能
  3. 检查语义搜索的排除行为
  4. 测试与其他过滤器(时间、大小)的组合使用
  5. 验证JSON输出是否包含排除路径信息

Added support for excluding specific directories from search results
via new --exclude parameter. Users can now provide comma-separated paths
to skip during searching. This improves search performance by avoiding
unnecessary directories like /tmp or .cache folders.

The implementation includes:
1. New CLI option --exclude in dfm-searcher
2. SemanticSearcher API extension for excluded paths
3. Integration with underlying search engines
4. Documentation updates with examples
5. Backward compatible with older Qt versions

Log: Added --exclude option to skip specified directories during search

Influence:
1. Test exclusion with various path formats (absolute, relative, with
spaces)
2. Verify search performance in directories containing excluded paths
3. Check semantic search exclusion behavior
4. Test combinations with other filters (time, size)
5. Verify JSON output includes excluded paths information

feat: 新增搜索目录排除功能

新增通过--exclude参数排除特定目录的功能。用户可通过逗号分隔的路径列表跳
过特定目录搜索,提高搜索性能(特别是跳过/tmp或.cache等无关目录)

实现包括:
1. dfm-searcher新增--exclude命令行选项
2. 扩展SemanticSearcher API支持排除路径
3. 底层搜索引擎集成
4. 文档更新并添加示例
5. 保持对旧版Qt的兼容性

Log: 新增--exclude选项可跳过指定目录的搜索

Influence:
1. 测试不同路径格式的排除功能(绝对路径、相对路径、含空格路径)
2. 验证包含排除路径的目录中的搜索性能
3. 检查语义搜索的排除行为
4. 测试与其他过滤器(时间、大小)的组合使用
5. 验证JSON输出是否包含排除路径信息

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:65分

■ 【总体评价】

代码实现了排除目录的搜索功能,但存在致命的编译错误
逻辑设计合理但因缺少SearchOptions类的方法实现导致无法编译扣35分

■ 【详细分析】

  • 1.语法逻辑(存在致命错误)✕

main.cppconfigureSearchOptions 函数和 semanticsearcher.cppdoSearch 函数中调用了 options.setSearchExcludedPaths(),但 diff 中并未在 SearchOptions 类中声明或实现该方法,导致编译失败
潜在问题:项目无法通过编译,功能完全不可用
建议:在 SearchOptions 类的头文件和源文件中补充 setSearchExcludedPaths 方法的声明与实现,并确保在底层搜索引擎中实际过滤这些路径

  • 2.代码质量(一般)✕

cli_options.cpp 中存在两处完全相同的解析 m_excludeOption 的代码块,违反了 DRY 原则,增加了维护成本
潜在问题:后续修改解析逻辑时容易遗漏其中一处,导致行为不一致
建议:将解析逻辑提取为一个独立的私有辅助函数,或在合适的公共位置统一处理

  • 3.代码性能(无性能问题)✓

使用 QStringList 传递路径并利用隐式共享机制,没有不必要的深拷贝,解析字符串使用 split 方法效率足够
建议:无需特别优化

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
总体风险描述:代码仅涉及路径字符串的解析与传递,未引入外部输入执行或注入风险,无安全漏洞

  • 建议:无需修复

■ 【改进建议代码示例】

// 在 searchoptions.h 中
class SearchOptions {
// ...
public:
    void setSearchExcludedPaths(const QStringList &paths);
    QStringList searchExcludedPaths() const;
private:
    QStringList m_excludedPaths;
};

// 在 searchoptions.cpp 中
void SearchOptions::setSearchExcludedPaths(const QStringList &paths)
{
    m_excludedPaths = paths;
}

QStringList SearchOptions::searchExcludedPaths() const
{
    return m_excludedPaths;
}

@deepin-ci-robot

Copy link
Copy Markdown

@Johnson-zs: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
github-pr-review-ci a7d5909 link true /test github-pr-review-ci

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@Johnson-zs

Copy link
Copy Markdown
Contributor Author

deepin pr auto review

★ 总体评分:65分

■ 【总体评价】

代码实现了排除目录的搜索功能,但存在致命的编译错误
逻辑设计合理但因缺少SearchOptions类的方法实现导致无法编译扣35分

■ 【详细分析】

  • 1.语法逻辑(存在致命错误)✕

main.cppconfigureSearchOptions 函数和 semanticsearcher.cppdoSearch 函数中调用了 options.setSearchExcludedPaths(),但 diff 中并未在 SearchOptions 类中声明或实现该方法,导致编译失败
潜在问题:项目无法通过编译,功能完全不可用
建议:在 SearchOptions 类的头文件和源文件中补充 setSearchExcludedPaths 方法的声明与实现,并确保在底层搜索引擎中实际过滤这些路径

  • 2.代码质量(一般)✕

cli_options.cpp 中存在两处完全相同的解析 m_excludeOption 的代码块,违反了 DRY 原则,增加了维护成本
潜在问题:后续修改解析逻辑时容易遗漏其中一处,导致行为不一致
建议:将解析逻辑提取为一个独立的私有辅助函数,或在合适的公共位置统一处理

  • 3.代码性能(无性能问题)✓

使用 QStringList 传递路径并利用隐式共享机制,没有不必要的深拷贝,解析字符串使用 split 方法效率足够
建议:无需特别优化

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
总体风险描述:代码仅涉及路径字符串的解析与传递,未引入外部输入执行或注入风险,无安全漏洞

  • 建议:无需修复

■ 【改进建议代码示例】

// 在 searchoptions.h 中
class SearchOptions {
// ...
public:
    void setSearchExcludedPaths(const QStringList &paths);
    QStringList searchExcludedPaths() const;
private:
    QStringList m_excludedPaths;
};

// 在 searchoptions.cpp 中
void SearchOptions::setSearchExcludedPaths(const QStringList &paths)
{
    m_excludedPaths = paths;
}

QStringList SearchOptions::searchExcludedPaths() const
{
    return m_excludedPaths;
}

接口是存在的

@Johnson-zs

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 4cf863d into linuxdeepin:master Jul 13, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants