BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

    Avoid deeply nested control flow statements.
    Open

              if (part === '\n' || part === '\r\n') {
                currentSelection.insertParagraph();
              } else if (part === '\t') {
                currentSelection.insertNodes([$createTabNode()]);
              } else {
    Severity: Major
    Found in resources/js/wysiwyg/lexical/clipboard/clipboard.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (childKey !== '') {
                    collabKeys.add(childKey);
                  }
      Severity: Major
      Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                for (let i = segmentsLength - 1; i >= 0; i--) {
                  const segment = segments[i];
                  const nextIndex = segment.index;
        
                  if (segment.isWordLike) {
        Severity: Major
        Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 45 mins to fix

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

          export function $getNextRightPreorderNode(
            startingNode: LexicalNode,
          ): LexicalNode | null {
            let node: LexicalNode | null = startingNode;
          
          
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/utils/index.ts - About 45 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 (nextSibling.nodeName === 'P') {
                      nextSibling = nextSibling.lastChild;
                    }
          Severity: Major
          Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    if (iColumn === 0) {
                      headerState |= TableCellHeaderStates.COLUMN;
                    }
            Severity: Major
            Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if ($isElementNode(anchorNode)) {
                            listItem.setFormat(anchorNode.getFormatType());
                            listItem.setIndent(anchorNode.getIndent());
                          }
              Severity: Major
              Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (listItemNode != null) {
                              listNodes.add($getTopListNode(listItemNode));
                            }
                Severity: Major
                Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          if (column === endColumn) {
                            // Overflowing right
                            const inSelectedArea = endColumn - cellStartColumn + 1;
                            cell.setColSpan(cell.__colSpan - inSelectedArea);
                          }
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              } else if ($isListItemNode(anchorNode)) {
                                const parent = anchorNode.getParentOrThrow();
                                append(list, parent.getChildren());
                                parent.replace(list);
                              }
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                            if (previousSibling) {
                              previousSibling.insertAfter(newListItem);
                            } else if (nextSibling) {
                              nextSibling.insertBefore(newListItem);
                            } else {
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 45 mins to fix

                        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

                          Function getCordsFromCellNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            getCordsFromCellNode(
                              tableCellNode: TableCellNode,
                              table: TableDOMTable,
                            ): {x: number; y: number} {
                              const {rows, domRows} = table;
                          Severity: Minor
                          Found in resources/js/wysiwyg/lexical/table/LexicalTableNode.ts - About 45 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 ($isListNode(parent)) {
                                        if (!handled.has(parentKey)) {
                                          const newListNode = $createListNode(listType);
                                          append(newListNode, parent.getChildren());
                                          parent.replace(newListNode);
                          Severity: Major
                          Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 45 mins to fix

                            Function redo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function redo(editor: LexicalEditor, historyState: HistoryState): void {
                              const redoStack = historyState.redoStack;
                              const undoStack = historyState.undoStack;
                            
                              if (redoStack.length !== 0) {
                            Severity: Minor
                            Found in resources/js/wysiwyg/lexical/history/index.ts - About 45 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 ($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 (iRow === 0) {
                                        headerState |= TableCellHeaderStates.ROW;
                                      }
                              Severity: Major
                              Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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

                                  Avoid deeply nested control flow statements.
                                  Open

                                                if (correctDOM === null) {
                                                  continue;
                                                }
                                  Severity: Major
                                  Found in resources/js/wysiwyg/lexical/core/LexicalMutations.ts - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language