BookStackApp/BookStack

View on GitHub
resources/js/wysiwyg/lexical/selection/lexical-node.ts

Summary

Maintainability
F
5 days
Test Coverage

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

export function $trimTextContentFromAnchor(
  editor: LexicalEditor,
  anchor: Point,
  delCount: number,
): void {
Severity: Minor
Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 1 day 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 $patchStyleText has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

export function $patchStyleText(
  selection: BaseSelection,
  patch: Record<
    string,
    | string
Severity: Minor
Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 1 day 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 $sliceSelectedTextNodeContent has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

export function $sliceSelectedTextNodeContent(
  selection: BaseSelection,
  textNode: TextNode,
): LexicalNode {
  const anchorAndFocus = selection.getStartEndPoints();
Severity: Minor
Found in resources/js/wysiwyg/lexical/selection/lexical-node.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 $patchStyleText has 106 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function $patchStyleText(
  selection: BaseSelection,
  patch: Record<
    string,
    | string
Severity: Major
Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix

    File lexical-node.ts has 336 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/selection/lexical-node.ts - About 4 hrs to fix

      Function $trimTextContentFromAnchor has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function $trimTextContentFromAnchor(
        editor: LexicalEditor,
        anchor: Point,
        delCount: number,
      ): void {
      Severity: Major
      Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix

        Function $sliceSelectedTextNodeContent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function $sliceSelectedTextNodeContent(
          selection: BaseSelection,
          textNode: TextNode,
        ): LexicalNode {
          const anchorAndFocus = selection.getStartEndPoints();
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                  if (anchorOffset < remaining) {
                    anchorOffset = currentNodeSize;
                  }
          Severity: Major
          Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    if (isSelected && splitStart === 0) {
                      const [excessNode] = currentNode.splitText(splitStart, splitEnd);
                      excessNode.remove();
                    } else {
                      const [, excessNode] = currentNode.splitText(splitStart, splitEnd);
            Severity: Major
            Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status