8000 fix: add qualifier check by akitaSummer · Pull Request #295 · eggjs/tegg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: add qualifier check #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 10, 2025
Merged

Conversation

akitaSummer
Copy link
Contributor
@akitaSummer akitaSummer commented Mar 10, 2025
Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • New Features

    • Added enhanced error handling to prevent duplicate qualifiers. The system now displays a clear error message if a qualifier already exists, ensuring consistency and preventing unintended duplicate entries.
    • Introduced an optional parameter for controlled replacement of qualifiers, allowing users to specify if existing qualifiers should be replaced.
  • Bug Fixes

    • Improved logic for qualifier handling to ensure proper validation before overwriting existing implementations.
  • Documentation

    • Updated the README to include guidance on overriding enumeration types with a force parameter.

Copy link
coderabbitai bot commented Mar 10, 2025

Walkthrough

This pull request updates the QualifierUtil, QualifierImplDecoratorUtil, and QualifierImplUtil classes by modifying the addProtoQualifier and addQualifierImpl methods to include an optional isForceReplacement parameter. This parameter allows for controlled replacement of existing qualifiers and implementations. Additionally, the generatorDecorator method in QualifierImplDecoratorUtil is updated to pass this new parameter, enhancing the handling of qualifiers in the application.

Changes

File Change Summary
core/core-decorator/.../QualifierUtil.ts Updated addProtoQualifier method to include isForceReplacement. Added error handling for existing qualifiers.
core/dynamic-inject/.../QualifierImplDecoratorUtil.ts Modified generatorDecorator method to accept isForceReplacement and pass it to addQualifierImpl and addProtoQualifier.
core/dynamic-inject/.../QualifierImplUtil.ts Updated addQualifierImpl method to include isForceReplacement and added error handling for existing implementations.
plugin/tegg/lib/AppLoadUnit.ts Updated invocation of QualifierUtil.addProtoQualifier to include a third parameter, true, for isForceReplacement.
core/types/dynamic-inject.ts Modified ImplDecorator type to accept an optional isForceReplacement parameter.
README.md Added a comment regarding the behavior of the enumeration and how to force an override.

Possibly related PRs

  • feat: support inject in constructor #237: The changes in the main PR are related to the modifications in the addProtoQualifier method, which is also referenced in the retrieved PR's updates to the generatorDecorator method that now includes the isForceReplacement parameter when calling addProtoQualifier.
  • feat: add default inject init type qualifier #255: The changes in the main PR are related to the modifications made to the addProtoQualifier method in the QualifierUtil class, which is also invoked in the retrieved PR's Inject decorator function, as both now utilize the isForceReplacement parameter.
  • feat: impl MultiInstanceInfo decorator #239: The changes in the main PR, which modify the addProtoQualifier method to include an isForceReplacement parameter, are related to the retrieved PR as it also introduces an isForceReplacement parameter in the generatorDecorator method, which calls addProtoQualifier.

Suggested reviewers

  • killagu

Poem

I'm a rabbit, hopping along,
Over code changes, singing a cheerful song.
With a skip and a jump, errors are now caught,
Keeping qualifiers unique, as it should be taught! 🥕✨
Code's in bloom, like a carrot field bright – a delight!
Hop on, dear coder, embrace the new light!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fengmk2 fengmk2 requested a review from Copilot March 10, 2025 07:37
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This pull request improves qualifier handling by introducing an optional force replacement parameter to prevent duplicate qualifier errors when explicitly intended.

  • Added an optional isForceReplacement parameter to both QualifierImplUtil.addQualifierImpl and QualifierUtil.addProtoQualifier
  • Updated QualifierImplDecoratorUtil and AppLoadUnit to propagate the new parameter and override behavior accordingly

Reviewed Changes

File Description
core/dynamic-inject/src/QualifierImplUtil.ts Updated addQualifierImpl to include an optional force replacement parameter
core/core-decorator/src/util/QualifierUtil.ts Updated addProtoQualifier to include an optional force replacement parameter
core/dynamic-inject/src/QualifierImplDecoratorUtil.ts Modified the decorator generator to forward the new parameter
plugin/tegg/lib/AppLoadUnit.ts Changed addProtoQualifier call to force replacement in default qualifiers

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

core/dynamic-inject/src/QualifierImplUtil.ts:7

  • Consider adding tests to verify that when isForceReplacement is true, the duplicate qualifier error is not thrown.
if (QualifierImplUtil.getQualifierImp(abstractClazz, qualifierValue) && !isForceReplacement) {

core/core-decorator/src/util/QualifierUtil.ts:8

  • Consider adding tests to ensure that passing a true value for isForceReplacement bypasses the duplicate qualifier error.
if (QualifierUtil.getQualifierValue(clazz, attribute) && !isForceReplacement) {

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
core/types/dynamic-inject.ts (1)

8-8: Good addition of the optional parameter.

The addition of the isForceReplacement optional parameter enhances the flexibility of the ImplDecorator type. This allows for explicit control over whether existing qualifier implementations should be replaced, which helps prevent accidental overrides while still allowing intentional replacements when needed.

Consider adding JSDoc comments to document this parameter's purpose and behavior to improve code readability and maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c92c0b7 and f2da86f.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • core/types/dynamic-inject.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Runner-ubuntu (22)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Analyze (javascript)

Copy link
Contributor
@killagu killagu left a comment

Choose a reason for hiding this comment

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

LGTM

@akitaSummer akitaSummer merged commit 6744088 into eggjs:master Mar 10, 2025
13 checks passed
@fengmk2
Copy link
Member
fengmk2 commented Mar 11, 2025

@akitaSummer pick 到 next 分支?😄

@killagu
Copy link
Contributor
killagu commented Mar 14, 2025
  • @eggjs/ajv-decorator@3.52.1
  • @eggjs/aop-decorator@3.52.1
  • @eggjs/controller-decorator@3.52.1
  • @eggjs/core-decorator@3.52.1
  • @eggjs/dal-decorator@3.52.1
  • @eggjs/dal-runtime@3.52.1
  • @eggjs/egg-module-common@3.52.1
  • @eggjs/eventbus-decorator@3.52.1
  • @eggjs/standalone-decorator@3.52.1
  • @eggjs/tegg@3.52.1
  • @eggjs/tegg-ajv-plugin@3.52.1
  • @eggjs/tegg-aop-plugin@3.52.1
  • @eggjs/tegg-aop-runtime@3.52.1
  • @eggjs/tegg-background-task@3.52.1
  • @eggjs/tegg-common-util@3.52.1
  • @eggjs/tegg-config@3.52.1
  • @eggjs/tegg-controller-plugin@3.52.1
  • @eggjs/tegg-dal-plugin@3.52.1
  • @eggjs/tegg-dynamic-inject@3.52.1
  • @eggjs/tegg-dynamic-inject-runtime@3.52.1
  • @eggjs/tegg-eventbus-plugin@3.52.1
  • @eggjs/tegg-eventbus-runtime@3.52.1
  • @eggjs/tegg-lifecycle@3.52.1
  • @eggjs/tegg-loader@3.52.1
  • @eggjs/tegg-metadata@3.52.1
  • @eggjs/tegg-orm-decorator@3.52.1
  • @eggjs/tegg-orm-plugin@3.52.1
  • @eggjs/tegg-plugin@3.52.1
  • @eggjs/tegg-runtime@3.52.1
  • @eggjs/tegg-schedule-decorator@3.52.1
  • @eggjs/tegg-schedule-plugin@3.52.1
  • @eggjs/tegg-standalone@3.52.1
  • @eggjs/tegg-transaction-decorator@3.52.1
  • @eggjs/tegg-types@3.52.1

killagu added a commit that referenced this pull request Mar 15, 2025
@coderabbitai coderabbitai bot mentioned this pull request Apr 2, 2025
4 tasks
gxkl added a commit that referenced this pull request Apr 17, 2025
gxkl added a commit that referenced this pull request Apr 21, 2025
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.

3 participants
0