BookStackApp/BookStack

View on GitHub
resources/js/wysiwyg/lexical/yjs/SyncCursors.ts

Summary

Maintainability
F
3 days
Test Coverage

File SyncCursors.ts has 451 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
Severity: Minor
Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 6 hrs to fix

    Function syncCursorPositions has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    export function syncCursorPositions(
      binding: Binding,
      provider: Provider,
    ): void {
      const awarenessStates = Array.from(provider.awareness.getStates());
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function updateCursor has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function updateCursor(
      binding: Binding,
      cursor: Cursor,
      nextSelection: null | CursorSelection,
      nodeMap: NodeMap,
    Severity: Major
    Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 3 hrs to fix

      Function updateCursor has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      function updateCursor(
        binding: Binding,
        cursor: Cursor,
        nextSelection: null | CursorSelection,
        nodeMap: NodeMap,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function syncCursorPositions has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function syncCursorPositions(
        binding: Binding,
        provider: Provider,
      ): void {
        const awarenessStates = Array.from(provider.awareness.getStates());
      Severity: Major
      Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 2 hrs to fix

        Function syncLexicalSelectionToYjs has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function syncLexicalSelectionToYjs(
          binding: Binding,
          provider: Provider,
          prevSelection: null | BaseSelection,
          nextSelection: null | BaseSelection,
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

          Function createRelativePosition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function createRelativePosition(
            point: Point,
            binding: Binding,
          ): null | RelativePosition {
            const collabNodeMap = binding.collabNodeMap;
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function createRelativePosition has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createRelativePosition(
            point: Point,
            binding: Binding,
          ): null | RelativePosition {
            const collabNodeMap = binding.collabNodeMap;
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

            Function $syncLocalCursorPosition has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function $syncLocalCursorPosition(
              binding: Binding,
              provider: Provider,
            ): void {
              const awareness = provider.awareness;
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

              Function $syncLocalCursorPosition has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export function $syncLocalCursorPosition(
                binding: Binding,
                provider: Provider,
              ): void {
                const awareness = provider.awareness;
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function syncLexicalSelectionToYjs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export function syncLexicalSelectionToYjs(
                binding: Binding,
                provider: Provider,
                prevSelection: null | BaseSelection,
                nextSelection: null | BaseSelection,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 55 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Avoid deeply nested control flow statements.
              Open

                        if (anchorCollabNode !== null && focusCollabNode !== null) {
                          const anchorKey = anchorCollabNode.getKey();
                          const focusKey = focusCollabNode.getKey();
                          selection = cursor.selection;
              
              
              Severity: Major
              Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 45 mins to fix

                Function createCursorSelection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  cursor: Cursor,
                  anchorKey: NodeKey,
                  anchorOffset: number,
                  focusKey: NodeKey,
                  focusOffset: number,
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 35 mins to fix

                  Function $setPoint has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function $setPoint(point: Point, key: NodeKey, offset: number): void {
                    if (point.key !== key || point.offset !== offset) {
                      let anchorNode = $getNodeByKey(key);
                      if (
                        anchorNode !== null &&
                  Severity: Minor
                  Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Avoid too many return statements within this function.
                  Open

                        return;
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return;
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status