Skip to content

fix: App operator!= uses OR of both fields - #3443

Draft
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fix/dde-157-app-operator-inequality
Draft

MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fix/dde-157-app-operator-inequality

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

修复内容

App::operator!=src/plugin-defaultapp/operation/category.h)误用 && 而非 ||——operator!= 本应为 operator== 的逻辑否定,却要求两个字段同时不同才返回 true,导致仅在一个字段(IdisUser)上不同的两个 App 被误判为「相等」。

改动

  • src/plugin-defaultapp/operation/category.hApp::operator!=&& 改为 ||,使其与 operator== 严格互为逻辑否定。
  • tests/ut_category.cpp(新增):覆盖修复后四种不等比较场景——仅 Id 不同 / 仅 isUser 不同 / 两字段都不同 / 完全相同。关键用例 App.InequalityUsesOrOfBothFields
  • tests/CMakeLists.txt:新增 ut_category.cpp + category.cpp 编译目标、plugin-defaultapp/operation include 路径、Qt::Test 链接。

验证

  • 单元测试:15/15 通过,category.cpp 行覆盖率 100%。
  • 代码审核:99 分通过(>70 阈值),无阻塞性问题。
  • 影响面:全仓无 operator!= 直接调用方,为潜伏态缺陷的纯修正,零运行时影响。

关联

  • Multica issue:DDE-157(f24e9fc3-639a-4fc0-beb1-6eb2c0c4c86c
  • 独立分支,与 DDE-158(同仓库另一缺陷修复)分支分开,两者无文件交集,可并行。

Summary by Sourcery

Fix App inequality comparisons and add comprehensive category unit-test coverage.

Bug Fixes:

  • Correct App::operator!= so apps differing in either Id or isUser are recognized as unequal.

Build:

  • Add category implementation and test sources to the unit-test target and link the required Qt Test module.

Tests:

  • Add unit coverage for App equality and inequality semantics and Category state changes, list management, deduplication, and signals.

1. Change App::operator!= from && to || so it negates operator==
2. Apps differing in one field were wrongly reported as equal
3. Add ut_category.cpp with four inequality test scenarios
4. Register ut_category in tests/CMakeLists.txt with Qt::Test link

Influence:
1. Verify operator!= returns true for Apps differing in one field
2. Verify operator!= returns false for identical Apps
3. Run ut_category unit tests, expect 15/15 passing

fix: 修正 App operator!= 为两字段的逻辑或

1. 将 App::operator!= 的 && 改为 ||,使其为 operator== 的逻辑否定
2. 仅一个字段不同的两个 App 此前被误判为相等
3. 新增 ut_category.cpp,覆盖修复后四种不等比较场景
4. 在 tests/CMakeLists.txt 注册 ut_category 并链接 Qt::Test

Influence:
1. 验证仅一个字段不同的 App 的 operator!= 返回 true
2. 验证完全相同的 App 的 operator!= 返回 false
3. 运行 ut_category 单元测试,预期 15/15 通过
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MyLeeJiEun

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

@sourcery-ai

sourcery-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes App::operator!= by changing && to ||, making it the logical complement of operator==, and adds comprehensive comparison/category unit tests with the required CMake integration.

Flow diagram for App inequality comparison

flowchart TD
    A[Compare App fields] --> B{Id differs?}
    B -->|Yes| D[operator!= returns true]
    B -->|No| C{isUser differs?}
    C -->|Yes| D
    C -->|No| E[operator!= returns false]
Loading

File-Level Changes

Change Details Files
Correct App::operator!= so it is the logical negation of equality across both identity fields.
  • Replace the conjunction of field differences with a disjunction.
  • Ensure apps differing in either Id or isUser compare as unequal.
src/plugin-defaultapp/operation/category.h
Add unit coverage for App comparison semantics and Category behavior.
  • Test equality and all four inequality combinations: same, Id-only difference, isUser-only difference, and both fields different.
  • Cover category initialization, signal emission guards, app routing, deduplication, removal, and clearing using QSignalSpy.
tests/ut_category.cpp
Integrate the new category tests and implementation into the test target.
  • Add the category test and source files to the executable.
  • Add the category operation include path and Qt Test linkage.
tests/CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.106
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3497

@deepin-bot

deepin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.107
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants