chore: fix most explicit-function-return-type warnings #656

Merged
Sainan merged 4 commits from explicit-return-types into main 2024-12-29 12:47:18 -08:00
Owner
No description provided.
coderabbitai[bot] commented 2024-12-28 21:57:05 -08:00 (Migrated from github.com)
Author
Owner

Warning

Rate limit exceeded

@Sainan has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 41 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 177744690d and ccda64e8b8.

📒 Files selected for processing (1)
  • src/services/recipeService.ts (2 hunks)

Walkthrough

The pull request focuses on enhancing type safety and clarity across multiple TypeScript files in the project. The changes primarily involve updating function signatures to explicitly define return types, which helps improve code readability and reduces potential type-related errors. These modifications span various services, controllers, helpers, and utility files, including inventoryService.ts, loginService.ts, configService.ts, and others.

The modifications do not alter the core logic or functionality of the existing code but instead provide more precise type annotations. This includes specifying return types for asynchronous functions, clarifying whether functions return a value or perform side effects, and ensuring that function signatures accurately represent their intended behavior. The changes reflect a systematic approach to strengthening the type system and improving overall code quality.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- This is an auto-generated comment: rate limited by coderabbit.ai --> > [!WARNING] > ## Rate limit exceeded > > @Sainan has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait **12 minutes and 41 seconds** before requesting another review. > > <details> > <summary>⌛ How to resolve this issue?</summary> > > After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. > > We recommend that you space out your commits to avoid hitting the rate limit. > > </details> > > > <details> > <summary>🚦 How do rate limits work?</summary> > > CodeRabbit enforces hourly rate limits for each developer per organization. > > Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. > > Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information. > > </details> > > <details> > <summary>📥 Commits</summary> > > Reviewing files that changed from the base of the PR and between 177744690dd40e447e241b10eb140ebb4e462f42 and ccda64e8b8ccf3ee258057d0799162829a7f4146. > > </details> > > <details> > <summary>📒 Files selected for processing (1)</summary> > > * `src/services/recipeService.ts` (2 hunks) > > </details> <!-- end of auto-generated comment: rate limited by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough The pull request focuses on enhancing type safety and clarity across multiple TypeScript files in the project. The changes primarily involve updating function signatures to explicitly define return types, which helps improve code readability and reduces potential type-related errors. These modifications span various services, controllers, helpers, and utility files, including `inventoryService.ts`, `loginService.ts`, `configService.ts`, and others. The modifications do not alter the core logic or functionality of the existing code but instead provide more precise type annotations. This includes specifying return types for asynchronous functions, clarifying whether functions return a value or perform side effects, and ensuring that function signatures accurately represent their intended behavior. The changes reflect a systematic approach to strengthening the type system and improving overall code quality. <!-- walkthrough_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjHYmgDZkeTeISo3oAM0QAPaK0LJ80Mm95LRCZNCGdcLAlEQiwIR3xcKlj8eV4yaAB3DCTELBJkYAA5XFYhah4ANgBWCuAAVWRy6ABlXSxsY0MTSBgKRkJnPCJSClU6RhZ2Th5+QVFxSRk5RRYVGnVNHT0u0xgEdHRsIeJyShpxpSmsbmgaDOhkEtZsxQUlNbUNbV19CCNuszAZBUJgAehY1yohEs1ioyFBGF4iFB5HwADEqIg+sgAMIxfBQmHULT4ZBcYAAIipwAAxDToABBACSIzOtAYDyeL0Egzs2HIBWACHSfLy6S89EQrlk0Hw8HSyEQJHaCUcPNl8ugAANURisVh6Lj8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XyXVLwF1zQcDcseWGVKXOjB5I+bnJrUkUu1Bw1WF8DqiXlYMFq4GSedgGjpjp3SgkqlrfKyKXIkhHU9DC/KKJvyMhzY6sozm/mDTCFf8/iD4FUUBKrxvZHRWkCub98bxlbaBZcqkUz8NeJy66GcqAkXKNuzKY6bmKXG9CHmQbayAEvgbWQjiAAfkwX2QHIW4tiW8QeXISbyoiggM0jGFw5WoMi/CT+UIkKLiJ7/dYWRKFkmocYZqLAIXgRIMDRS5hKgN/xICVFrAOIfuiOCbzmEzgTEkQpjDxpC1Yw5i6hHmGJrpKxQGcidJqIAoaT0StfJmPYvOyYDYCsIkAlpOpr8Taa9qb0ppF7nZSbigZd9DOBWQF11kRlF/G3OXBKx4cxBDyT3KmU0AjIyXKMtXSWX3zK6yQ9ZfLJ6kfzdlKrfZRR0OUtlh8FK9QVSt7C0qyA9K0BoyuZXUBVBdXJFRHlBDGrWo6vHuj6uNmUrqVga4NfQiZXqCzgkxcmcoyjUoqSA5AKgNeUgRdBQAPQcsP0EGCr1hgBE8uD9GmC3AIePM3BAUv9zrAvgWwX4EYF2CXBLM+AGSEWGQAJRS4NmBgDJBeW+BS1PagAIwAB2edQABYF1FQAAJwAAGbJAurXVkAl1s6sgAACYF106oQNOu3Unqt1ZAdQAup3UVB91zgBdfuq7UAgYAkwPtQOsNDDqsQSc+gDJD6BdqgAA --> <!-- internal state end --> <!-- tips_start --> --- 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? <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - 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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. ([Beta](https://docs.coderabbit.ai/early-access#beta)) - `@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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-12-28 22:00:21 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 1

🧹 Nitpick comments (16)
src/controllers/api/getFriendsController.ts (1)

3-3: Consider aligning the content type with the actual response format.
Currently, the header specifies "text/html", but the response data is a JSON object ({}\n). For clarity and correctness, consider setting the content type to "application/json" if the payload is intended to be interpreted as JSON.

"Content-Type": "text/html",
+ "Content-Type": "application/json",
src/services/loadoutService.ts (1)

5-5: Use a more descriptive error or handle gracefully.
When loadout is not found, the function throws a generic error. Consider using a custom error class or a dedicated error type for clearer error handling and potential logging improvements.

src/services/recipeService.ts (1)

7-7: Optional improvement: define a dedicated interface.

Returning an inline type clarifies the function’s Promise result; however, creating a dedicated interface (e.g., IStartRecipeResult) would further improve readability and consistency.

-export const startRecipe = async (recipeName: string, accountId: string): Promise<{ RecipeId: { $oid?: string } }> => {
+interface IStartRecipeResult {
+  RecipeId: {
+    $oid?: string;
+  };
+}
+
+export const startRecipe = async (recipeName: string, accountId: string): Promise<IStartRecipeResult> => {
src/services/purchaseService.ts (2)

28-28: Explicit return type improves readability.

By specifying : string, future contributors clearly see that this function must return a string. Make sure to handle any unexpected cases (e.g., no slash in storeItem) to avoid runtime errors.


34-34: Return type clarity for getStoreItemTypesCategory.

Similar to the above change, explicitly returning a string enhances type safety. Consider validating or sanitizing the substring result in case typesItem doesn't follow the expected "/Types" structure.

src/services/inventoryService.ts (11)

369-369: Add a graceful error check for invalid sentinelName.

If sentinelName isn't present in ExportSentinels, undefined behavior may occur. Consider throwing an error or returning early.


402-406: Validate array index after pushing.

If sentinelIndex is less than 1, accessing sentinelIndex - 1 might be out of bounds. A quick boundary check prevents runtime errors.


460-464: Add a safety check on suitIndex boundary.

If suitIndex happens to be 0 or negative, accessing [suitIndex - 1] could cause an error. A simple check ensures greater stability.


467-472: Validate slot parameters.

Consider validating slotAmount and extraAmount for negative or unexpected values to avoid inconsistent slot states.


666-666: Consider returning the updated items.

addMiscItems mutates the inventory in place. Returning the new or updated items could improve testability and clarity.


681-684: Extract shared push-or-increment logic.

addShipDecorations closely resembles other add methods. A shared helper function could reduce duplication and ease updates.


699-699: Refactor repeated array update patterns.

addConsumables uses the same push-or-increment pattern found in other methods. Consider extracting a common utility function for maintainability.


714-714: Promote DRY by unifying array updates.

addRecipes just like addConsumables, addMiscItems, etc., could reuse a utility function to limit code repetition.


729-729: Centralize repeated push-or-increment logic.

addMods duplicates array-updating patterns. A single helper would streamline future maintenance.


746-746: Apply a unified approach to array updates.

addFusionTreasures also does item lookups and increments. A consolidated helper can reduce code duplication.


807-807: Consider returning the updated missions.

addMissionComplete mutates inventory.Missions but doesn't return anything. Returning the updated missions could help with testing or chaining in other parts of the code.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dbb0fe4bf and 177744690d.

📒 Files selected for processing (14)
  • src/controllers/api/getFriendsController.ts (1 hunks)
  • src/helpers/inventoryHelpers.ts (2 hunks)
  • src/helpers/purchaseHelpers.ts (1 hunks)
  • src/helpers/stringHelpers.ts (1 hunks)
  • src/middleware/middleware.ts (1 hunks)
  • src/models/inventoryModels/inventoryModel.ts (1 hunks)
  • src/services/configService.ts (1 hunks)
  • src/services/inventoryService.ts (16 hunks)
  • src/services/loadoutService.ts (1 hunks)
  • src/services/loginService.ts (1 hunks)
  • src/services/missionInventoryUpdateService.ts (1 hunks)
  • src/services/purchaseService.ts (1 hunks)
  • src/services/recipeService.ts (1 hunks)
  • src/utils/logger.ts (1 hunks)
🔇 Additional comments (15)
src/services/loadoutService.ts (2)

3-3: Ensure that ILoadoutDatabase matches the shape of loadout.toJSON().
While importing ILoadoutDatabase improves type clarity, verify that all fields returned by loadout.toJSON() align with the interface. Mismatches may cause runtime errors or type confusion.


13-13: Validate serialization before returning.
Confirm that any additional fields or sensitive data are not inadvertently exposed by toJSON(). You could sanitize or omit certain fields before returning if necessary.

src/helpers/purchaseHelpers.ts (1)

8-8: Explicit return type improves clarity.
Specifying SlotPurchaseName clarifies the function's output and helps prevent incorrect usage. This change aligns well with the type-safe objective of this PR.

src/middleware/middleware.ts (1)

4-4: Function signature and behavior are consistent.
Defining the function’s return type as void clarifies that it ends the request by sending a 404 response without returning additional data. This matches Express middleware usage.

src/helpers/stringHelpers.ts (1)

20-20: Explicit return type enhances clarity.

By specifying a return type of number, you make it clear to consumers that the function can potentially return -1 when the searchWord is not found, or a valid index otherwise. This aligns well with JavaScript’s String.indexOf() convention.

src/services/configService.ts (1)

59-59: Clearer return type benefits maintainability.

By declaring a Promise<void> return type, you convey that the function’s asynchronous operation completes without returning a value, making it clearer for future maintainers.

src/services/loginService.ts (2)

37-37: Explicit return type is a great addition.

Declaring Promise<Types.ObjectId> makes it clear to consumers that this function resolves to the saved document's _id. This is a good step towards ensuring type safety.


43-43: Void return type is consistent and appropriate.

By explicitly returning Promise<void>, this clarifies that no value is returned while still emphasizing that the function is asynchronous.

src/utils/logger.ts (1)

106-106: Clear indication of no return value.

Declaring the return type as void removes ambiguity and signals to maintainers that this function doesn't produce a result. Good job on improving type clarity.

src/services/missionInventoryUpdateService.ts (1)

187-187: Explicit return type ensures thorough type checks.

Specifying void here aligns with the rest of the code that updates the InventoryChanges and also clarifies the function's contract. This helps avoid confusion for anyone expecting a returned value.

src/models/inventoryModels/inventoryModel.ts (1)

329-329: Consider verifying that v.$oid is present before returning its string.

If there's a possibility that the object is null or lacks the $oid property, a runtime error may be thrown.

src/services/inventoryService.ts (4)

50-50: Good practice to specify Promise<void>.

Declaring an explicit Promise<void> clarifies that the function is asynchronous with no returned value.


760-763: Great clarity on async return type.

Specifying Promise<void> for updateChallengeProgress is consistent with the broader code style and clarifies the function’s purpose.


775-775: No issues detected here.

addSeasonalChallengeHistory follows the same pattern as other helper methods. The logic looks good.


789-792: ⚠️ Potential issue

Fix the .markModified path.

You're modifying Progress, but the code references .ItemCount. Update it to reference .Progress:

- inventory.markModified(`ChallengeProgress.${itemIndex}.ItemCount`);
+ inventory.markModified(`ChallengeProgress.${itemIndex}.Progress`);

Likely invalid or redundant comment.

**Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments (16)</summary><blockquote> <details> <summary>src/controllers/api/getFriendsController.ts (1)</summary><blockquote> `3-3`: **Consider aligning the content type with the actual response format.** Currently, the header specifies `"text/html"`, but the response data is a JSON object (`{}\n`). For clarity and correctness, consider setting the content type to `"application/json"` if the payload is intended to be interpreted as JSON. ```diff "Content-Type": "text/html", + "Content-Type": "application/json", ``` </blockquote></details> <details> <summary>src/services/loadoutService.ts (1)</summary><blockquote> `5-5`: **Use a more descriptive error or handle gracefully.** When `loadout` is not found, the function throws a generic error. Consider using a custom error class or a dedicated error type for clearer error handling and potential logging improvements. </blockquote></details> <details> <summary>src/services/recipeService.ts (1)</summary><blockquote> `7-7`: **Optional improvement: define a dedicated interface.** Returning an inline type clarifies the function’s `Promise` result; however, creating a dedicated interface (e.g., `IStartRecipeResult`) would further improve readability and consistency. ```diff -export const startRecipe = async (recipeName: string, accountId: string): Promise<{ RecipeId: { $oid?: string } }> => { +interface IStartRecipeResult { + RecipeId: { + $oid?: string; + }; +} + +export const startRecipe = async (recipeName: string, accountId: string): Promise<IStartRecipeResult> => { ``` </blockquote></details> <details> <summary>src/services/purchaseService.ts (2)</summary><blockquote> `28-28`: **Explicit return type improves readability.** By specifying `: string`, future contributors clearly see that this function must return a string. Make sure to handle any unexpected cases (e.g., no slash in `storeItem`) to avoid runtime errors. --- `34-34`: **Return type clarity for `getStoreItemTypesCategory`.** Similar to the above change, explicitly returning a string enhances type safety. Consider validating or sanitizing the substring result in case `typesItem` doesn't follow the expected "/Types" structure. </blockquote></details> <details> <summary>src/services/inventoryService.ts (11)</summary><blockquote> `369-369`: **Add a graceful error check for invalid sentinelName.** If `sentinelName` isn't present in `ExportSentinels`, undefined behavior may occur. Consider throwing an error or returning early. --- `402-406`: **Validate array index after pushing.** If `sentinelIndex` is less than 1, accessing `sentinelIndex - 1` might be out of bounds. A quick boundary check prevents runtime errors. --- `460-464`: **Add a safety check on `suitIndex` boundary.** If `suitIndex` happens to be 0 or negative, accessing `[suitIndex - 1]` could cause an error. A simple check ensures greater stability. --- `467-472`: **Validate slot parameters.** Consider validating `slotAmount` and `extraAmount` for negative or unexpected values to avoid inconsistent slot states. --- `666-666`: **Consider returning the updated items.** `addMiscItems` mutates the inventory in place. Returning the new or updated items could improve testability and clarity. --- `681-684`: **Extract shared push-or-increment logic.** `addShipDecorations` closely resembles other add methods. A shared helper function could reduce duplication and ease updates. --- `699-699`: **Refactor repeated array update patterns.** `addConsumables` uses the same push-or-increment pattern found in other methods. Consider extracting a common utility function for maintainability. --- `714-714`: **Promote DRY by unifying array updates.** `addRecipes` just like `addConsumables`, `addMiscItems`, etc., could reuse a utility function to limit code repetition. --- `729-729`: **Centralize repeated push-or-increment logic.** `addMods` duplicates array-updating patterns. A single helper would streamline future maintenance. --- `746-746`: **Apply a unified approach to array updates.** `addFusionTreasures` also does item lookups and increments. A consolidated helper can reduce code duplication. --- `807-807`: **Consider returning the updated missions.** `addMissionComplete` mutates `inventory.Missions` but doesn't return anything. Returning the updated missions could help with testing or chaining in other parts of the code. </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 9dbb0fe4bf2b0ffa66c91aee08bd53d59d0a296c and 177744690dd40e447e241b10eb140ebb4e462f42. </details> <details> <summary>📒 Files selected for processing (14)</summary> * `src/controllers/api/getFriendsController.ts` (1 hunks) * `src/helpers/inventoryHelpers.ts` (2 hunks) * `src/helpers/purchaseHelpers.ts` (1 hunks) * `src/helpers/stringHelpers.ts` (1 hunks) * `src/middleware/middleware.ts` (1 hunks) * `src/models/inventoryModels/inventoryModel.ts` (1 hunks) * `src/services/configService.ts` (1 hunks) * `src/services/inventoryService.ts` (16 hunks) * `src/services/loadoutService.ts` (1 hunks) * `src/services/loginService.ts` (1 hunks) * `src/services/missionInventoryUpdateService.ts` (1 hunks) * `src/services/purchaseService.ts` (1 hunks) * `src/services/recipeService.ts` (1 hunks) * `src/utils/logger.ts` (1 hunks) </details> <details> <summary>🔇 Additional comments (15)</summary> <details> <summary>src/services/loadoutService.ts (2)</summary> `3-3`: **Ensure that `ILoadoutDatabase` matches the shape of `loadout.toJSON()`.** While importing `ILoadoutDatabase` improves type clarity, verify that all fields returned by `loadout.toJSON()` align with the interface. Mismatches may cause runtime errors or type confusion. --- `13-13`: **Validate serialization before returning.** Confirm that any additional fields or sensitive data are not inadvertently exposed by `toJSON()`. You could sanitize or omit certain fields before returning if necessary. </details> <details> <summary>src/helpers/purchaseHelpers.ts (1)</summary> `8-8`: **Explicit return type improves clarity.** Specifying `SlotPurchaseName` clarifies the function's output and helps prevent incorrect usage. This change aligns well with the type-safe objective of this PR. </details> <details> <summary>src/middleware/middleware.ts (1)</summary> `4-4`: **Function signature and behavior are consistent.** Defining the function’s return type as `void` clarifies that it ends the request by sending a 404 response without returning additional data. This matches Express middleware usage. </details> <details> <summary>src/helpers/stringHelpers.ts (1)</summary> `20-20`: **Explicit return type enhances clarity.** By specifying a return type of `number`, you make it clear to consumers that the function can potentially return `-1` when the `searchWord` is not found, or a valid index otherwise. This aligns well with JavaScript’s `String.indexOf()` convention. </details> <details> <summary>src/services/configService.ts (1)</summary> `59-59`: **Clearer return type benefits maintainability.** By declaring a `Promise<void>` return type, you convey that the function’s asynchronous operation completes without returning a value, making it clearer for future maintainers. </details> <details> <summary>src/services/loginService.ts (2)</summary> `37-37`: **Explicit return type is a great addition.** Declaring `Promise<Types.ObjectId>` makes it clear to consumers that this function resolves to the saved document's `_id`. This is a good step towards ensuring type safety. --- `43-43`: **Void return type is consistent and appropriate.** By explicitly returning `Promise<void>`, this clarifies that no value is returned while still emphasizing that the function is asynchronous. </details> <details> <summary>src/utils/logger.ts (1)</summary> `106-106`: **Clear indication of no return value.** Declaring the return type as `void` removes ambiguity and signals to maintainers that this function doesn't produce a result. Good job on improving type clarity. </details> <details> <summary>src/services/missionInventoryUpdateService.ts (1)</summary> `187-187`: **Explicit return type ensures thorough type checks.** Specifying `void` here aligns with the rest of the code that updates the `InventoryChanges` and also clarifies the function's contract. This helps avoid confusion for anyone expecting a returned value. </details> <details> <summary>src/models/inventoryModels/inventoryModel.ts (1)</summary> `329-329`: **Consider verifying that `v.$oid` is present before returning its string.** If there's a possibility that the object is null or lacks the `$oid` property, a runtime error may be thrown. </details> <details> <summary>src/services/inventoryService.ts (4)</summary> `50-50`: **Good practice to specify `Promise<void>`.** Declaring an explicit `Promise<void>` clarifies that the function is asynchronous with no returned value. --- `760-763`: **Great clarity on async return type.** Specifying `Promise<void>` for `updateChallengeProgress` is consistent with the broader code style and clarifies the function’s purpose. --- `775-775`: **No issues detected here.** `addSeasonalChallengeHistory` follows the same pattern as other helper methods. The logic looks good. --- `789-792`: _:warning: Potential issue_ **Fix the `.markModified` path.** You're modifying `Progress`, but the code references `.ItemCount`. Update it to reference `.Progress`: ```diff - inventory.markModified(`ChallengeProgress.${itemIndex}.ItemCount`); + inventory.markModified(`ChallengeProgress.${itemIndex}.Progress`); ``` > Likely invalid or redundant comment. </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
coderabbitai[bot] (Migrated from github.com) commented 2024-12-28 22:00:20 -08:00
Author
Owner

💡 Codebase verification

Based on the search results, I can see that:

  1. The toMongoDate function is used in several places to convert dates for MongoDB storage
  2. The function is used in critical paths like inventory models and guild controllers
  3. There's no existing date validation in the codebase

Given that this function is used in multiple important places and handles date conversions for database storage, adding validation is a good practice to prevent invalid data from being stored.

Add date validation to prevent invalid date storage

The suggestion to validate the date object is correct. Invalid dates could lead to incorrect data being stored in MongoDB, which could cause issues in data retrieval and processing. The proposed validation using isNaN(date.getTime()) is a standard and reliable way to check for invalid Date objects.

🔗 Analysis chain

Consider validating the date object.

While returning an IMongoDate improves type safety, ensure the passed date is valid. If date is invalid (NaN), the result may produce incorrect values. You could check for isNaN(date.getTime()) before constructing the IMongoDate.

 export const toMongoDate = (date: Date): IMongoDate => {
+  if (isNaN(date.getTime())) {
+    throw new Error("Invalid date provided.");
+  }
   return { $date: { $numberLong: date.getTime().toString() } };
 };

Let me verify the concern by checking how this function is used in the codebase and if there are any existing date validation mechanisms.


Let me try another search to find the interface definition and check how the function is used.


Let me check one more thing to see if there's any existing error handling for invalid dates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Find usages of toMongoDate function
rg "toMongoDate" -B 2 -A 2

# Check if there's any date validation utility in the codebase
rg "isValid.*Date|validateDate|date.*validation" -B 2 -A 2

# Look for the interface definition
ast-grep --pattern 'interface IMongoDate {
  $$$
}'

Length of output: 69307


Script:

#!/bin/bash
# Find the interface definition
rg "interface IMongoDate" -A 5

# Look for any date validation in the codebase
rg "isNaN\(.*\.getTime\(\)\)" -A 2

# Check the implementation and usage context
rg "toMongoDate" -A 2 src/helpers/inventoryHelpers.ts

Length of output: 455


Script:

#!/bin/bash
# Check for any error handling around date conversions
rg "new Error.*date" -B 2 -A 2

# Look for any date-related utility functions
rg "function.*Date" -B 2 -A 2

# Check the files that use toMongoDate to see if they validate dates
rg -l "toMongoDate" | xargs rg "getTime|isNaN|invalid.*date" -B 2 -A 2

Length of output: 65671

_:bulb: Codebase verification_ Based on the search results, I can see that: 1. The `toMongoDate` function is used in several places to convert dates for MongoDB storage 2. The function is used in critical paths like inventory models and guild controllers 3. There's no existing date validation in the codebase Given that this function is used in multiple important places and handles date conversions for database storage, adding validation is a good practice to prevent invalid data from being stored. **Add date validation to prevent invalid date storage** The suggestion to validate the date object is correct. Invalid dates could lead to incorrect data being stored in MongoDB, which could cause issues in data retrieval and processing. The proposed validation using `isNaN(date.getTime())` is a standard and reliable way to check for invalid Date objects. <details> <summary>🔗 Analysis chain</summary> **Consider validating the date object.** While returning an IMongoDate improves type safety, ensure the passed `date` is valid. If `date` is invalid (`NaN`), the result may produce incorrect values. You could check for `isNaN(date.getTime())` before constructing the IMongoDate. ```diff export const toMongoDate = (date: Date): IMongoDate => { + if (isNaN(date.getTime())) { + throw new Error("Invalid date provided."); + } return { $date: { $numberLong: date.getTime().toString() } }; }; ``` --- Let me verify the concern by checking how this function is used in the codebase and if there are any existing date validation mechanisms. --- Let me try another search to find the interface definition and check how the function is used. --- Let me check one more thing to see if there's any existing error handling for invalid dates. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Find usages of toMongoDate function rg "toMongoDate" -B 2 -A 2 # Check if there's any date validation utility in the codebase rg "isValid.*Date|validateDate|date.*validation" -B 2 -A 2 # Look for the interface definition ast-grep --pattern 'interface IMongoDate { $$$ }' ``` Length of output: 69307 --- Script: ```shell #!/bin/bash # Find the interface definition rg "interface IMongoDate" -A 5 # Look for any date validation in the codebase rg "isNaN\(.*\.getTime\(\)\)" -A 2 # Check the implementation and usage context rg "toMongoDate" -A 2 src/helpers/inventoryHelpers.ts ``` Length of output: 455 --- Script: ```shell #!/bin/bash # Check for any error handling around date conversions rg "new Error.*date" -B 2 -A 2 # Look for any date-related utility functions rg "function.*Date" -B 2 -A 2 # Check the files that use toMongoDate to see if they validate dates rg -l "toMongoDate" | xargs rg "getTime|isNaN|invalid.*date" -B 2 -A 2 ``` Length of output: 65671 </details> <!-- This is an auto-generated comment by CodeRabbit -->
Sign in to join this conversation.
No description provided.