BookStackApp/BookStack

View on GitHub
resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts

Summary

Maintainability
F
2 wks
Test Coverage

File LexicalTableSelectionHelpers.ts has 1595 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: Major
Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 4 days to fix

    Function applyTableHandlers has 709 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function applyTableHandlers(
      tableNode: TableNode,
      tableElement: HTMLTableElementWithWithTableSelectionState,
      editor: LexicalEditor,
      hasTabHandler: boolean,
    Severity: Major
    Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 3 days to fix

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

      function $handleArrowKey(
        editor: LexicalEditor,
        event: KeyboardEvent,
        direction: Direction,
        tableNode: TableNode,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 2 days 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 applyTableHandlers has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
      Open

      export function applyTableHandlers(
        tableNode: TableNode,
        tableElement: HTMLTableElementWithWithTableSelectionState,
        editor: LexicalEditor,
        hasTabHandler: boolean,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 $handleArrowKey has 271 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function $handleArrowKey(
        editor: LexicalEditor,
        event: KeyboardEvent,
        direction: Direction,
        tableNode: TableNode,
      Severity: Major
      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 1 day to fix

        Function selectTableNodeInDirection has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        const selectTableNodeInDirection = (
          tableObserver: TableObserver,
          tableNode: TableNode,
          x: number,
          y: number,
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 getTable has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getTable(tableElement: HTMLElement): TableDOMTable {
          const domRows: TableDOMRows = [];
          const grid = {
            columns: 0,
            domRows,
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 2 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 getTable has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function getTable(tableElement: HTMLElement): TableDOMTable {
          const domRows: TableDOMRows = [];
          const grid = {
            columns: 0,
            domRows,
        Severity: Major
        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 2 hrs to fix

          Function selectTableNodeInDirection has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const selectTableNodeInDirection = (
            tableObserver: TableObserver,
            tableNode: TableNode,
            x: number,
            y: number,
          Severity: Major
          Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 2 hrs to fix

            Function deleteTextHandler has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const deleteTextHandler = (command: LexicalCommand<boolean>) => () => {
                const selection = $getSelection();
            
                if (!$isSelectionInTable(selection, tableNode)) {
                  return false;
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 2 hrs to fix

              Function adjustFocusNodeInDirection has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              const adjustFocusNodeInDirection = (
                tableObserver: TableObserver,
                tableNode: TableNode,
                x: number,
                y: number,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 $getTableEdgeCursorPosition has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function $getTableEdgeCursorPosition(
                editor: LexicalEditor,
                selection: RangeSelection,
                tableNode: TableNode,
              ) {
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 1 hr to fix

                Function $deleteCellHandler has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const $deleteCellHandler = (
                    event: KeyboardEvent | ClipboardEvent | null,
                  ): boolean => {
                    const selection = $getSelection();
                
                
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 1 hr to fix

                  Function adjustFocusNodeInDirection has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const adjustFocusNodeInDirection = (
                    tableObserver: TableObserver,
                    tableNode: TableNode,
                    x: number,
                    y: number,
                  Severity: Minor
                  Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 1 hr to fix

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

                    export function $forEachTableCell(
                      grid: TableDOMTable,
                      cb: (
                        cell: TableDOMCell,
                        lexicalNode: LexicalNode,
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 $getTableEdgeCursorPosition has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function $getTableEdgeCursorPosition(
                      editor: LexicalEditor,
                      selection: RangeSelection,
                      tableNode: TableNode,
                    ) {
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 (newSelection) {
                                    newSelection.anchor.set(
                                      tableNode.getKey(),
                                      selection.isBackward() ? tableNode.getChildrenSize() : 0,
                                      'element',
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              if ($isRootOrShadowRoot(focusNode)) {
                                const selectedNode = selection.getNodes()[0];
                                if (selectedNode) {
                                  const tableCellNode = $findMatchingParent(
                                    selectedNode,
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (!tableObserver.isSelecting) {
                                        setTimeout(() => {
                                          const {onMouseUp, onMouseMove} = createMouseHandlers();
                                          tableObserver.isSelecting = true;
                                          editorWindow.addEventListener('mouseup', onMouseUp);
                        Severity: Major
                        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                              } else if ($isRangeSelection(selection)) {
                                const tableCellNode = $findMatchingParent(
                                  selection.anchor.getNode(),
                                  (n) => $isTableCellNode(n),
                                );
                          Severity: Major
                          Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if (
                                      selection &&
                                      !selection.is(prevSelection) &&
                                      ($isTableSelection(selection) || $isTableSelection(prevSelection)) &&
                                      tableObserver.tableSelection &&
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 40 mins to fix

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

                                editor: LexicalEditor,
                                event: KeyboardEvent,
                                direction: Direction,
                                tableNode: TableNode,
                                tableObserver: TableObserver,
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 35 mins to fix

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

                                export function getDOMCellFromTarget(node: Node): TableDOMCell | null {
                                  let currentNode: ParentNode | Node | null = node;
                                
                                  while (currentNode != null) {
                                    const nodeName = currentNode.nodeName;
                                Severity: Minor
                                Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.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 undefined;
                                Severity: Major
                                Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

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

                                    Avoid too many return statements within this function.
                                    Open

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

                                      Avoid too many return statements within this function.
                                      Open

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

                                        Avoid too many return statements within this function.
                                        Open

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

                                          Avoid too many return statements within this function.
                                          Open

                                              return 'last';
                                          Severity: Major
                                          Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

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

                                              Avoid too many return statements within this function.
                                              Open

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

                                                Avoid too many return statements within this function.
                                                Open

                                                        return $handleTableExit(event, anchorNode, tableNode, direction);
                                                Severity: Major
                                                Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

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

                                                    Avoid too many return statements within this function.
                                                    Open

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

                                                      Avoid too many return statements within this function.
                                                      Open

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

                                                        Avoid too many return statements within this function.
                                                        Open

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

                                                          Avoid too many return statements within this function.
                                                          Open

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

                                                            Avoid too many return statements within this function.
                                                            Open

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

                                                              Avoid too many return statements within this function.
                                                              Open

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

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                      return adjustFocusNodeInDirection(
                                                                        tableObserver,
                                                                        tableNodeFromSelection,
                                                                        cords.x,
                                                                        cords.y,
                                                                Severity: Major
                                                                Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return 'first';
                                                                  Severity: Major
                                                                  Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

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

                                                                      Avoid too many return statements within this function.
                                                                      Open

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

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                                return selectTableNodeInDirection(
                                                                                  tableObserver,
                                                                                  tableNode,
                                                                                  cords.x,
                                                                                  cords.y,
                                                                        Severity: Major
                                                                        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

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

                                                                            Avoid too many return statements within this function.
                                                                            Open

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

                                                                              Avoid too many return statements within this function.
                                                                              Open

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

                                                                                Avoid too many return statements within this function.
                                                                                Open

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

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

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

                                                                                    Avoid too many return statements within this function.
                                                                                    Open

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

                                                                                      Avoid too many return statements within this function.
                                                                                      Open

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

                                                                                        Avoid too many return statements within this function.
                                                                                        Open

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

                                                                                          Avoid too many return statements within this function.
                                                                                          Open

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

                                                                                            Avoid too many return statements within this function.
                                                                                            Open

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

                                                                                              Avoid too many return statements within this function.
                                                                                              Open

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

                                                                                                Avoid too many return statements within this function.
                                                                                                Open

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

                                                                                                  Avoid too many return statements within this function.
                                                                                                  Open

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

                                                                                                    Avoid too many return statements within this function.
                                                                                                    Open

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

                                                                                                      Avoid too many return statements within this function.
                                                                                                      Open

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

                                                                                                        Avoid too many return statements within this function.
                                                                                                        Open

                                                                                                                return $handleArrowKey(
                                                                                                                  editor,
                                                                                                                  event,
                                                                                                                  direction,
                                                                                                                  anchorCellTable,
                                                                                                        Severity: Major
                                                                                                        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 30 mins to fix

                                                                                                          Avoid too many return statements within this function.
                                                                                                          Open

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

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

                                                                                                            function $handleTableExit(
                                                                                                              event: KeyboardEvent,
                                                                                                              anchorNode: LexicalNode,
                                                                                                              tableNode: TableNode,
                                                                                                              direction: 'backward' | 'forward',
                                                                                                            Severity: Minor
                                                                                                            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 25 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

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                    if ($isTableSelection(selection)) {
                                                                                                                      tableObserver.formatCells(payload);
                                                                                                            
                                                                                                                      return true;
                                                                                                                    } else if ($isRangeSelection(selection)) {
                                                                                                            resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts on lines 342..359

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 59.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                                if ($isTableSelection(selection)) {
                                                                                                                  if (event) {
                                                                                                                    event.preventDefault();
                                                                                                                    event.stopPropagation();
                                                                                                                  }
                                                                                                            resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts on lines 420..433

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 59.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                            export function $findTableNode(node: LexicalNode): null | TableNode {
                                                                                                              const tableNode = $findMatchingParent(node, $isTableNode);
                                                                                                              return $isTableNode(tableNode) ? tableNode : null;
                                                                                                            }
                                                                                                            resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts on lines 1295..1298

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 52.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                            export function $findCellNode(node: LexicalNode): null | TableCellNode {
                                                                                                              const cellNode = $findMatchingParent(node, $isTableCellNode);
                                                                                                              return $isTableCellNode(cellNode) ? cellNode : null;
                                                                                                            }
                                                                                                            resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts on lines 1300..1303

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 52.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                            Open

                                                                                                            export const getDOMSelection = (
                                                                                                              targetWindow: Window | null,
                                                                                                            ): Selection | null =>
                                                                                                              CAN_USE_DOM ? (targetWindow || window).getSelection() : null;
                                                                                                            resources/js/wysiwyg/lexical/clipboard/clipboard.ts on lines 35..36

                                                                                                            Duplicated Code

                                                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                            Tuning

                                                                                                            This issue has a mass of 46.

                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                            Refactorings

                                                                                                            Further Reading

                                                                                                            There are no issues that match your filters.

                                                                                                            Category
                                                                                                            Status