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 incorrect tree snapshot encoding/decoding #836

Merged
merged 7 commits into from
Jun 3, 2024
Merged

Conversation

hackerwins
Copy link
Member

@hackerwins hackerwins commented May 31, 2024

What this PR does / why we need it?

Fix incorrect tree snapshot encoding/decoding

The following issues exist when encoding and ecoding snapshots of Tree:

  • Removed nodes are missing
  • Update incorrect size

This commit fixes the incorrect tree snapshot encoding/decoding logic.

Any background context you want to provide?

What are the relevant tickets?

Address yorkie-team/yorkie#880

Checklist

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Added getNodeSize method to the Tree class for retrieving the size of the tree node.
  • Enhancements

    • Improved tree size management with new methods for updating descendants' and ancestors' sizes.
    • Enhanced error handling for uninitialized contexts or trees.
  • Tests

    • Added new test case to verify encoding and decoding of tree structures within a Document object.

Copy link

coderabbitai bot commented May 31, 2024

Walkthrough

The recent update enhances the tree traversal and size management functionalities across various modules. Notably, the traverse function in CRDTTree was renamed to traverseAll, and new methods were added to manage node sizes. Additionally, encoding and decoding of tree structures within documents are now tested, ensuring robust tree handling in the system.

Changes

Files Change Summaries
src/api/converter.ts Renamed traverse to traverseAll and added root.updateDescendantsSize() call.
src/document/crdt/tree.ts Renamed traverse to traverseAll and added getNodeSize method to CRDTTree class.
src/document/json/tree.ts Added getNodeSize method to Tree class with error handling for uninitialized context or tree.
src/util/index_tree.ts Added updateDescendantsSize method and modified updateAncestorsSize and prepend methods.
test/unit/api/converter_test.ts Updated import statement and added a test case for encoding and decoding tree structures in documents.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Converter
    participant CRDTTree
    participant Document

    User->>Converter: Call traverseAll()
    Converter->>CRDTTree: traverseAll()
    CRDTTree-->>Converter: Return traversal result
    User->>Document: Create new Tree
    Document->>CRDTTree: Get Node Size
    CRDTTree-->>Document: Return size
    Document-->>User: Return Tree with size
Loading

Poem

In the code where trees reside,
New methods now take stride.
TraverseAll and sizes bright,
Make our trees a wondrous sight.
With tests to keep our code in line,
Our forest grows, robust, divine. 🌳✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link

codecov bot commented May 31, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 80.65%. Comparing base (f292131) to head (c09a992).

Files Patch % Lines
src/document/json/tree.ts 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #836      +/-   ##
==========================================
+ Coverage   80.45%   80.65%   +0.20%     
==========================================
  Files          59       59              
  Lines        4543     4554      +11     
  Branches      921      922       +1     
==========================================
+ Hits         3655     3673      +18     
+ Misses        619      614       -5     
+ Partials      269      267       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hackerwins hackerwins force-pushed the snapshot-test branch 2 times, most recently from 1e9f047 to e4a157a Compare June 3, 2024 01:27
@hackerwins hackerwins changed the title Snapshot test Fix incorrect tree snapshot encoding decoding Jun 3, 2024
@hackerwins hackerwins changed the title Fix incorrect tree snapshot encoding decoding Fix incorrect tree snapshot encoding/decoding Jun 3, 2024
@hackerwins hackerwins marked this pull request as ready for review June 3, 2024 01:34
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: 1

Outside diff range and nitpick comments (4)
src/api/converter.ts (4)

Line range hint 142-142: Avoid using template literals where not necessary.

- `unsupported type: ${valueType}`
+ 'unsupported type: ' + valueType

Also applies to: 267-267, 752-752


Line range hint 376-376: Remove non-null assertions to ensure code robustness. Consider adding null checks or handling potential null values gracefully.

- pbTextNodePos.createdAt!
+ pbTextNodePos.createdAt ? pbTextNodePos.createdAt : defaultTimeTicket

Also applies to: 396-396, 422-422, 430-430, 449-449, 497-497, 821-821, 900-900, 905-905, 911-911, 914-914, 928-928, 938-938, 949-949


Line range hint 686-686: Specify a more explicit type instead of using any.

- function toText(text: CRDTText<Record<string, any>>): PbJSONElement {
+ function toText(text: CRDTText<Record<string, string>>): PbJSONElement {

Line range hint 806-808: Prefer using for...of loops over forEach for better performance and readability.

- Object.entries(pbPresences).forEach(([actorID, pbPresence]) => {
+ for (const [actorID, pbPresence] of Object.entries(pbPresences)) {

Also applies to: 843-845

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f292131 and e4a157a.

Files selected for processing (5)
  • src/api/converter.ts (3 hunks)
  • src/document/crdt/tree.ts (2 hunks)
  • src/document/json/tree.ts (1 hunks)
  • src/util/index_tree.ts (4 hunks)
  • test/unit/api/converter_test.ts (2 hunks)
Additional context used
Biome
test/unit/api/converter_test.ts

[error] 27-27: The computed expression can be simplified without the use of a string literal.


[error] 28-28: The computed expression can be simplified without the use of a string literal.


[error] 29-29: The computed expression can be simplified without the use of a string literal.


[error] 24-84: This function expression can be turned into an arrow function.


[error] 100-101: Do not use template literals if interpolation and special-character handling are not needed.


[error] 108-108: Unexpected any. Specify a different type.


[error] 113-113: Unexpected any. Specify a different type.


[error] 84-117: This function expression can be turned into an arrow function.


[error] 117-124: This function expression can be turned into an arrow function.


[error] 23-124: This function expression can be turned into an arrow function.

src/document/json/tree.ts

[error] 86-86: This variable implicitly has the any type.


[error] 118-118: This variable implicitly has the any type.


[error] 125-125: This variable implicitly has the any type.


[error] 217-217: Forbidden non-null assertion.


[error] 281-281: Unexpected any. Specify a different type.


[error] 293-293: Forbidden non-null assertion.


[error] 317-317: Unexpected any. Specify a different type.


[error] 332-332: Forbidden non-null assertion.


[error] 339-339: Forbidden non-null assertion.


[error] 374-374: Forbidden non-null assertion.


[error] 381-381: Forbidden non-null assertion.


[error] 411-411: Forbidden non-null assertion.


[error] 422-422: Forbidden non-null assertion.


[error] 429-429: Forbidden non-null assertion.


[error] 433-433: Forbidden non-null assertion.


[error] 440-440: Forbidden non-null assertion.


[error] 444-444: Forbidden non-null assertion.


[error] 447-447: Forbidden non-null assertion.


[error] 449-449: Forbidden non-null assertion.


[error] 16-17: All these imports are only used as types.

src/util/index_tree.ts

[error] 190-190: Unexpected any. Specify a different type.


[error] 197-197: Forbidden non-null assertion.


[error] 197-197: Unexpected any. Specify a different type.


[error] 198-198: Forbidden non-null assertion.


[error] 252-252: Forbidden non-null assertion.


[error] 252-252: Unexpected any. Specify a different type.


[error] 294-294: Unexpected any. Specify a different type.


[error] 310-310: Unexpected any. Specify a different type.


[error] 393-393: Forbidden non-null assertion.


[error] 393-393: Unexpected any. Specify a different type.


[error] 442-442: Unexpected any. Specify a different type.


[error] 818-818: Forbidden non-null assertion.


[error] 824-824: Forbidden non-null assertion.


[error] 828-828: Forbidden non-null assertion.


[error] 833-833: Forbidden non-null assertion.


[error] 948-948: Forbidden non-null assertion.


[error] 956-956: Forbidden non-null assertion.


[error] 16-17: All these imports are only used as types.


[error] 516-516: Reassigning a function parameter is confusing.


[error] 759-759: Reassigning a function parameter is confusing.

src/document/crdt/tree.ts

[error] 151-151: This variable implicitly has the any type.


[error] 154-154: Forbidden non-null assertion.


[error] 155-155: Forbidden non-null assertion.


[error] 160-160: Forbidden non-null assertion.


[error] 242-242: Forbidden non-null assertion.


[error] 326-328: This else clause can be omitted because previous branches break early.


[error] 452-452: The assignment should not be in an expression.


[error] 547-547: Forbidden non-null assertion.


[error] 550-550: Forbidden non-null assertion.


[error] 591-591: Forbidden non-null assertion.


[error] 596-596: Forbidden non-null assertion.


[error] 722-722: Change to an optional chain.


[error] 724-735: Template literals are preferred over string concatenation.


[error] 877-877: Unexpected any. Specify a different type.


[error] 890-890: Forbidden non-null assertion.


[error] 891-891: Forbidden non-null assertion.


[error] 891-891: Forbidden non-null assertion.


[error] 896-896: Forbidden non-null assertion.


[error] 974-974: Forbidden non-null assertion.


[error] 1039-1039: Forbidden non-null assertion.

src/api/converter.ts

[error] 142-142: Do not use template literals if interpolation and special-character handling are not needed.


[error] 267-267: Do not use template literals if interpolation and special-character handling are not needed.


[error] 376-376: Forbidden non-null assertion.


[error] 396-396: Forbidden non-null assertion.


[error] 422-422: Forbidden non-null assertion.


[error] 430-430: Forbidden non-null assertion.


[error] 449-449: Forbidden non-null assertion.


[error] 497-497: Forbidden non-null assertion.


[error] 686-686: Unexpected any. Specify a different type.


[error] 752-752: Do not use template literals if interpolation and special-character handling are not needed.


[error] 806-808: Prefer for...of instead of forEach.


[error] 821-821: Forbidden non-null assertion.


[error] 843-845: Prefer for...of instead of forEach.


[error] 900-900: Forbidden non-null assertion.


[error] 905-905: Forbidden non-null assertion.


[error] 911-911: Forbidden non-null assertion.


[error] 914-914: Forbidden non-null assertion.


[error] 928-928: Forbidden non-null assertion.


[error] 938-938: Forbidden non-null assertion.


[error] 949-949: Forbidden non-null assertion.

Additional comments not posted (10)
test/unit/api/converter_test.ts (1)

20-20: Updated import statement to include Tree class aligns with the new functionality for handling tree structures.

src/document/json/tree.ts (1)

256-265: The new method getNodeSize correctly checks initialization before proceeding, which is good practice for error handling. Ensure that the tree is properly initialized in all use cases to avoid runtime errors.

src/util/index_tree.ts (3)

137-138: The method updateAncestorsSize has been updated to correctly reflect changes in node sizes up the tree, which is crucial for maintaining the integrity of tree size calculations.


150-168: The method updateDescendantsSize effectively recalculates the size of all descendant nodes, ensuring accurate size tracking within the tree.


300-301: The new method prepend is specifically used for creating nodes from snapshots, which aligns with the intended enhancements for handling tree structures more effectively.

src/document/crdt/tree.ts (2)

1280-1282: The method getNodeSize correctly returns the size of the nodeMapByID LLRBTree.


777-777: Ensure proper handling of node registration in traverseAll.

Verification successful

The nodeMapByID.put operations are present in multiple contexts within the src/document/crdt/tree.ts file. The code appears to handle node registration in various methods, including traverseAll, registerNode, and within other operations.

  • traverseAll method: Registers nodes during traversal.
  • registerNode method: Explicitly registers a given node.
  • Another context within a loop: Registers nodes conditionally.

These instances suggest that node registration is handled in different parts of the code, potentially ensuring that nodes are registered correctly without duplicates.

  • Lines around traverseAll:

    this.indexTree.traverseAll((node) => {
      this.nodeMapByID.put(node.id, node);
    });
  • Lines around registerNode:

    public registerNode(node: CRDTTreeNode): void {
      this.nodeMapByID.put(node.id, node);
    }
  • Another context:

    this.nodeMapByID.put(node.id, node);

Given the evidence, it appears that the node registration is handled properly in the code.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all nodes are correctly registered without duplicates or omissions.

# Test: Search for duplicate node registrations. Expect: No duplicates.
rg --type python $'this.nodeMapByID.put(node.id, node)' src/document/crdt/tree.ts

Length of output: 113



Script:

#!/bin/bash
# Description: Verify that all nodes are correctly registered without duplicates or omissions.

# Test: Search for duplicate node registrations. Expect: No duplicates.
rg --type typescript $'this.nodeMapByID.put(node.id, node)' src/document/crdt/tree.ts

Length of output: 121



Script:

#!/bin/bash
# Description: Verify that all nodes are correctly registered without duplicates or omissions.

# Test: Search for duplicate node registrations. Expect: No duplicates.
rg 'this.nodeMapByID.put(node.id, node)' src/document/crdt/tree.ts

Length of output: 68



Script:

#!/bin/bash
# Description: Verify the presence and usage of the `nodeMapByID` variable in the file.

# Test: Search for the `nodeMapByID` variable declaration and its related operations.
rg 'nodeMapByID' src/document/crdt/tree.ts

Length of output: 433



Script:

#!/bin/bash
# Description: Verify the context around `put` operations to ensure proper handling of node registration.

# Test: Extract lines around `put` operations for detailed inspection.
rg -C 5 'nodeMapByID.put' src/document/crdt/tree.ts

Length of output: 931

src/api/converter.ts (3)

108-108: Renamed function traverse to traverseAll to better reflect its functionality.


604-604: Refactored tree traversal logic to use traverseAll for improved clarity and maintainability.


1050-1050: Added call to updateDescendantsSize to ensure tree size is correctly updated, addressing the PR's objective to fix size updates during encoding/decoding.

test/unit/api/converter_test.ts Outdated Show resolved Hide resolved
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: 2

Outside diff range and nitpick comments (12)
test/unit/api/converter_test.ts (1)

Line range hint 91-124: Refactor test function to use arrow function for consistency.

- it('should encode and decode tree properly', function () {
+ it('should encode and decode tree properly', () => {
Tools
Biome

[error] 107-108: Do not use template literals if interpolation and special-character handling are not needed.

src/document/crdt/tree.ts (7)

Line range hint 151-151: Please specify a type for this variable to avoid implicit 'any' type.

- let variable;
+ let variable: SpecificType; // Replace 'SpecificType' with the actual type

Line range hint 154-154: Avoid using non-null assertions. Consider adding proper checks or handling potential null values gracefully.

- value!;
+ value ? value : defaultValue; // Replace 'defaultValue' with an appropriate fallback

Also applies to: 155-155, 160-160, 242-242, 547-547, 550-550, 591-591, 596-596, 890-890, 891-891, 896-896, 974-974, 1039-1039


Line range hint 326-328: This else clause is redundant as previous branches break early. Simplifying this can enhance readability.

- else {
-   // code
- }

Line range hint 452-452: Avoid assignments within expressions for clearer and more predictable code behavior.

- if ((variable = value)) {
+ variable = value;
+ if (variable) {

Line range hint 722-722: Consider using optional chaining to safely access properties.

- object.property.subProperty
+ object?.property?.subProperty

Line range hint 724-735: Prefer template literals over string concatenation for better readability and performance.

- "string1" + variable + "string2"
+ `string1${variable}string2`

Line range hint 877-877: Specify a type instead of using 'any' to ensure type safety.

- let variable: any;
+ let variable: SpecificType; // Replace 'SpecificType' with the actual type
src/api/converter.ts (4)

Line range hint 142-142: Avoid using template literals when not necessary.

- throw new YorkieError(Code.Unsupported, `unsupported type: ${valueType}`);
+ throw new YorkieError(Code.Unsupported, 'unsupported type: ' + valueType);

Also applies to: 267-267, 752-752


Line range hint 376-376: Avoid using non-null assertions. Consider adding null checks or using optional chaining.

- pbOperation.body.value!;
+ pbOperation.body.value ?? throw new Error('Operation value is undefined');

Also applies to: 396-396, 422-422, 430-430, 449-449, 497-497, 821-821, 900-900, 905-905, 911-911, 914-914, 928-928, 938-938, 949-949


Line range hint 686-686: Specify a type instead of using any.

- function toText(text: CRDTText<Record<string, any>>): PbJSONElement {
+ function toText(text: CRDTText<Record<string, string>>): PbJSONElement {

Line range hint 806-808: Prefer using for...of instead of forEach for better performance and readability.

- Object.entries(pbPresences).forEach(([actorID, pbPresence]) => {
+ for (const [actorID, pbPresence] of Object.entries(pbPresences)) {

Also applies to: 843-845

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e4a157a and c09a992.

Files selected for processing (5)
  • src/api/converter.ts (3 hunks)
  • src/document/crdt/tree.ts (2 hunks)
  • src/document/json/tree.ts (1 hunks)
  • src/util/index_tree.ts (4 hunks)
  • test/unit/api/converter_test.ts (2 hunks)
Additional context used
Biome
test/unit/api/converter_test.ts

[error] 27-27: The computed expression can be simplified without the use of a string literal.


[error] 28-28: The computed expression can be simplified without the use of a string literal.


[error] 29-29: The computed expression can be simplified without the use of a string literal.


[error] 24-84: This function expression can be turned into an arrow function.


[error] 84-91: This function expression can be turned into an arrow function.


[error] 107-108: Do not use template literals if interpolation and special-character handling are not needed.


[error] 91-124: This function expression can be turned into an arrow function.


[error] 23-124: This function expression can be turned into an arrow function.

src/document/json/tree.ts

[error] 86-86: This variable implicitly has the any type.


[error] 118-118: This variable implicitly has the any type.


[error] 125-125: This variable implicitly has the any type.


[error] 217-217: Forbidden non-null assertion.


[error] 281-281: Unexpected any. Specify a different type.


[error] 293-293: Forbidden non-null assertion.


[error] 317-317: Unexpected any. Specify a different type.


[error] 332-332: Forbidden non-null assertion.


[error] 339-339: Forbidden non-null assertion.


[error] 374-374: Forbidden non-null assertion.


[error] 381-381: Forbidden non-null assertion.


[error] 411-411: Forbidden non-null assertion.


[error] 422-422: Forbidden non-null assertion.


[error] 429-429: Forbidden non-null assertion.


[error] 433-433: Forbidden non-null assertion.


[error] 440-440: Forbidden non-null assertion.


[error] 444-444: Forbidden non-null assertion.


[error] 447-447: Forbidden non-null assertion.


[error] 449-449: Forbidden non-null assertion.


[error] 16-17: All these imports are only used as types.

src/util/index_tree.ts

[error] 190-190: Unexpected any. Specify a different type.


[error] 197-197: Forbidden non-null assertion.


[error] 197-197: Unexpected any. Specify a different type.


[error] 198-198: Forbidden non-null assertion.


[error] 252-252: Forbidden non-null assertion.


[error] 252-252: Unexpected any. Specify a different type.


[error] 294-294: Unexpected any. Specify a different type.


[error] 310-310: Unexpected any. Specify a different type.


[error] 393-393: Forbidden non-null assertion.


[error] 393-393: Unexpected any. Specify a different type.


[error] 442-442: Unexpected any. Specify a different type.


[error] 818-818: Forbidden non-null assertion.


[error] 824-824: Forbidden non-null assertion.


[error] 828-828: Forbidden non-null assertion.


[error] 833-833: Forbidden non-null assertion.


[error] 948-948: Forbidden non-null assertion.


[error] 956-956: Forbidden non-null assertion.


[error] 16-17: All these imports are only used as types.


[error] 516-516: Reassigning a function parameter is confusing.


[error] 759-759: Reassigning a function parameter is confusing.

src/document/crdt/tree.ts

[error] 151-151: This variable implicitly has the any type.


[error] 154-154: Forbidden non-null assertion.


[error] 155-155: Forbidden non-null assertion.


[error] 160-160: Forbidden non-null assertion.


[error] 242-242: Forbidden non-null assertion.


[error] 326-328: This else clause can be omitted because previous branches break early.


[error] 452-452: The assignment should not be in an expression.


[error] 547-547: Forbidden non-null assertion.


[error] 550-550: Forbidden non-null assertion.


[error] 591-591: Forbidden non-null assertion.


[error] 596-596: Forbidden non-null assertion.


[error] 722-722: Change to an optional chain.


[error] 724-735: Template literals are preferred over string concatenation.


[error] 877-877: Unexpected any. Specify a different type.


[error] 890-890: Forbidden non-null assertion.


[error] 891-891: Forbidden non-null assertion.


[error] 891-891: Forbidden non-null assertion.


[error] 896-896: Forbidden non-null assertion.


[error] 974-974: Forbidden non-null assertion.


[error] 1039-1039: Forbidden non-null assertion.

src/api/converter.ts

[error] 142-142: Do not use template literals if interpolation and special-character handling are not needed.


[error] 267-267: Do not use template literals if interpolation and special-character handling are not needed.


[error] 376-376: Forbidden non-null assertion.


[error] 396-396: Forbidden non-null assertion.


[error] 422-422: Forbidden non-null assertion.


[error] 430-430: Forbidden non-null assertion.


[error] 449-449: Forbidden non-null assertion.


[error] 497-497: Forbidden non-null assertion.


[error] 686-686: Unexpected any. Specify a different type.


[error] 752-752: Do not use template literals if interpolation and special-character handling are not needed.


[error] 806-808: Prefer for...of instead of forEach.


[error] 821-821: Forbidden non-null assertion.


[error] 843-845: Prefer for...of instead of forEach.


[error] 900-900: Forbidden non-null assertion.


[error] 905-905: Forbidden non-null assertion.


[error] 911-911: Forbidden non-null assertion.


[error] 914-914: Forbidden non-null assertion.


[error] 928-928: Forbidden non-null assertion.


[error] 938-938: Forbidden non-null assertion.


[error] 949-949: Forbidden non-null assertion.

Additional comments not posted (8)
test/unit/api/converter_test.ts (1)

108-108: Avoid using template literals when not necessary.

- assert.equal(doc.getRoot().tree.toXML(), /*html*/ `<r><p>14</p></r>`);
+ assert.equal(doc.getRoot().tree.toXML(), '<r><p>14</p></r>');

Likely invalid or redundant comment.

Tools
Biome

[error] 107-108: Do not use template literals if interpolation and special-character handling are not needed.

src/document/json/tree.ts (1)

259-265: Ensure proper error handling for uninitialized context or tree in getNodeSize.

src/util/index_tree.ts (1)

151-168: Ensure that updateDescendantsSize correctly updates the size of descendants.

src/document/crdt/tree.ts (2)

777-777: The method traverseAll is used to populate nodeMapByID. Ensure that all nodes are correctly handled during traversal.


1280-1282: The getNodeSize method provides the size of the nodeMapByID LLRBTree, which is crucial for understanding the scale of the tree structure at any given point.

src/api/converter.ts (3)

108-108: Renamed function traverse to traverseAll to better reflect its functionality.


604-604: Correctly updated the function call to traverseAll to align with the renaming.


1050-1050: Added call to updateDescendantsSize to ensure the size of descendants is correctly updated, aligning with PR objectives.

test/unit/api/converter_test.ts Show resolved Hide resolved
src/util/index_tree.ts Show resolved Hide resolved
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