Skip to content
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

fix(shared-utils): Fix addressing in getConfigValue #16358

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

norda-gunni
Copy link
Contributor

@norda-gunni norda-gunni commented Oct 10, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced the configuration value retrieval process for better namespacing.
    • Updated the structure of mock configuration for improved organization.
  • Bug Fixes

    • Corrected the method of accessing configuration values to ensure accuracy.

@norda-gunni norda-gunni requested a review from a team as a code owner October 10, 2024 14:58
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Walkthrough

The changes involve modifications to the getConfigValue function in the shared.utils.ts file. The type of the configService parameter has been simplified, and the method for retrieving configuration values has been updated to include a prefix for namespacing. Additionally, the mockConfig object in the test files has been restructured to encapsulate properties under a new key, SharedModuleConfig, while the instantiation of ConfigService has been simplified. Other functions and test logic remain unchanged.

Changes

File Change Summary
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.ts Updated getConfigValue method signature to simplify configService type and modified key retrieval to include SharedModuleConfig. prefix.
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.spec.ts Restructured mockConfig to nest properties under SharedModuleConfig and simplified ConfigService instantiation.
libs/application/template-api-modules/src/lib/modules/templates/social-insurance-administration/social-insurance-administration.service.spec.ts Updated mockConfig to nest templateApi under SharedModuleConfig, no changes to test logic.

Possibly related PRs

Suggested labels

automerge, test everything

Suggested reviewers

  • rafnarnason
  • RunarVestmann
  • HjorturJ

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cbc5962 and 2e1f568.

📒 Files selected for processing (2)
  • libs/application/template-api-modules/src/lib/modules/shared/shared.utils.spec.ts (2 hunks)
  • libs/application/template-api-modules/src/lib/modules/templates/social-insurance-administration/social-insurance-administration.service.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.spec.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/template-api-modules/src/lib/modules/templates/social-insurance-administration/social-insurance-administration.service.spec.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (4)
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.spec.ts (3)

Line range hint 1-105: Approve overall structure and adherence to coding guidelines

The file demonstrates good adherence to coding guidelines:

  1. It uses TypeScript for type definitions and imports, enhancing type safety.
  2. The tests focus on specific utility functions, supporting reusability across different NextJS apps.
  3. The restructured configuration may improve tree-shaking and bundling practices.

These aspects align well with the guidelines for files in the libs/**/* pattern, emphasizing reusability, TypeScript usage, and effective bundling practices.


97-97: Approve ConfigService instantiation simplification, verify type inference

The simplification of the ConfigService instantiation enhances code readability. This change aligns with TypeScript best practices by leveraging type inference.

To ensure that type safety is maintained, please run the following command to check if TypeScript correctly infers the SharedModuleConfig type:

#!/bin/bash
# Description: Verify type inference for ConfigService

# Test: Check ConfigService usage and type inference
rg --type typescript "new ConfigService<.*?>\(" -g "!*.spec.ts"

If the command returns no results, it suggests that the type is being correctly inferred in the actual implementation.


6-31: Approve restructuring of mockConfig, verify correctness

The restructuring of mockConfig to include a SharedModuleConfig key improves organization and likely better reflects the actual configuration structure. This change enhances reusability and type safety across different NextJS apps.

To ensure this restructuring is consistent with the actual configuration used in the application, please run the following command:

This will help confirm that the mock configuration accurately represents the real configuration structure.

libs/application/template-api-modules/src/lib/modules/templates/social-insurance-administration/social-insurance-administration.service.spec.ts (1)

11-14: LGTM! Consider verifying configuration usage.

The restructuring of the mockConfig object improves modularity by introducing the SharedModuleConfig namespace. This change aligns well with the reusability principle mentioned in the coding guidelines for libs/**/* files.

To ensure consistency across the codebase, please run the following script to verify the usage of SharedModuleConfig:

This will help identify any places where the configuration might need to be updated to match the new structure.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

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.

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.ts (1)

28-28: Consider maintaining specific type for ConfigService

The change from ConfigService<SharedModuleConfig> to ConfigService simplifies the type but might reduce type safety. Consider keeping the specific type to ensure that only valid configuration keys are accessed.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b8b850d and cbc5962.

📒 Files selected for processing (1)
  • libs/application/template-api-modules/src/lib/modules/shared/shared.utils.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (2)
libs/application/template-api-modules/src/lib/modules/shared/shared.utils.ts (2)

31-31: Approve the change in configuration value retrieval

The modification to prefix the key with SharedModuleConfig. when calling configService.get() is a good practice. It ensures proper namespacing of configuration keys, which can prevent conflicts and improve maintainability.


Line range hint 1-66: Verify compliance with coding guidelines for libs//* files**

While the changes are limited to the getConfigValue function, please ensure that the entire file adheres to the following guidelines for libs/**/* files:

  1. Components and hooks should be reusable across different NextJS apps.
  2. TypeScript should be used for defining props and exporting types.
  3. The code should follow effective tree-shaking and bundling practices.

The current implementation seems to comply with these guidelines, but it's worth a final check to ensure full compliance.

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.74%. Comparing base (0c4b341) to head (cb5465e).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16358   +/-   ##
=======================================
  Coverage   36.73%   36.74%           
=======================================
  Files        6804     6804           
  Lines      140861   140837   -24     
  Branches    40118    40109    -9     
=======================================
  Hits        51751    51751           
+ Misses      89110    89086   -24     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.44% <0.00%> (ø)
application-template-api-modules 27.95% <100.00%> (-0.02%) ⬇️
download-service 44.20% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
web 1.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...api-modules/src/lib/modules/shared/shared.utils.ts 82.75% <100.00%> (ø)

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c4b341...cb5465e. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 10, 2024

Datadog Report

All test runs 7398aa6 🔗

6 Total Test Services: 0 Failed, 6 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 10 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.02s 1 no change Link
application-system-api 0 0 0 120 2 3m 28.69s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 31.99s 1 decreased (-0.01%) Link
download-service 0 0 0 1 0 22.12s 1 no change Link
portals-admin-regulations-admin 0 0 0 24 0 16.56s 1 no change Link
web 0 0 0 84 0 31.29s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 30.16% (-0.01%) - Details

@norda-gunni norda-gunni requested a review from a team as a code owner October 10, 2024 15:16
@norda-gunni norda-gunni added the automerge Merge this PR as soon as all checks pass label Oct 10, 2024
Copy link
Member

@ylfahfa ylfahfa left a comment

Choose a reason for hiding this comment

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

lgtm

@kodiakhq kodiakhq bot merged commit ca1cc4e into main Oct 10, 2024
49 checks passed
@kodiakhq kodiakhq bot deleted the fix/shared-utils-getConfigValue branch October 10, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants