BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

Function moveNativeSelectionBackward has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

function moveNativeSelectionBackward() {
  const domSelection = window.getSelection()!;
  let anchorNode = domSelection.anchorNode!;
  let anchorOffset = domSelection.anchorOffset!;

Severity: Minor
Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.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 $applyAllTransforms has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

function $applyAllTransforms(
  editorState: EditorState,
  editor: LexicalEditor,
): void {
  const dirtyLeaves = editor._dirtyLeaves;
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.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

File SearchRunner.php has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace BookStack\Search;

use BookStack\Entities\EntityProvider;
Severity: Minor
Found in app/Search/SearchRunner.php - About 3 hrs to fix

    Function $insertTableColumn__EXPERIMENTAL has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function $insertTableColumn__EXPERIMENTAL(insertAfter = true): void {
      const selection = $getSelection();
      invariant(
        $isRangeSelection(selection) || $isTableSelection(selection),
        'Expected a RangeSelection or TableSelection',
    Severity: Major
    Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 3 hrs to fix

      Function $internalResolveSelectionPoint has 94 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function $internalResolveSelectionPoint(
        dom: Node,
        offset: number,
        lastPoint: null | PointType,
        editor: LexicalEditor,
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

        Function formatText has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          formatText(formatType: TextFormatType): void {
            if (this.isCollapsed()) {
              this.toggleFormat(formatType);
              // When changing format, we should stop composition
              $setCompositionKey(null);
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

          Function buildCellMap has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              protected buildCellMap(table: CustomTableNode) {
                  const rowsAndCells: CustomTableCellNode[][] = [];
                  const setCell = (x: number, y: number, cell: CustomTableCellNode) => {
                      if (typeof rowsAndCells[y] === 'undefined') {
                          rowsAndCells[y] = [];
          Severity: Minor
          Found in resources/js/wysiwyg/utils/table-map.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 syncChildrenFromLexical has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            syncChildrenFromLexical(
              binding: Binding,
              nextLexicalNode: ElementNode,
              prevNodeMap: null | NodeMap,
              dirtyElements: null | Map<NodeKey, IntentionallyMarkedAsDirtyElement>,
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.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 $setListThemeClassNames has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          function $setListThemeClassNames(
            dom: HTMLElement,
            editorThemeClasses: EditorThemeClasses,
            node: ListNode,
          ): void {
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/list/LexicalListNode.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 $insertTableColumn__EXPERIMENTAL has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          export function $insertTableColumn__EXPERIMENTAL(insertAfter = true): void {
            const selection = $getSelection();
            invariant(
              $isRangeSelection(selection) || $isTableSelection(selection),
              'Expected a RangeSelection or TableSelection',
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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 $handleIndent has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          export function $handleIndent(listItemNode: ListItemNode): void {
            // go through each node and decide where to move it.
            const removed = new Set<NodeKey>();
          
            if (isNestedListNode(listItemNode) || removed.has(listItemNode.getKey())) {
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/list/formatList.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 $updateSelectionResolveTextNodes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          function $updateSelectionResolveTextNodes(selection: RangeSelection): void {
            const anchor = selection.anchor;
            const anchorOffset = anchor.offset;
            const focus = selection.focus;
            const focusOffset = focus.offset;
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.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 $toggleLink has 92 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function $toggleLink(
            url: null | string,
            attributes: LinkAttributes = {},
          ): void {
            const {target, title} = attributes;
          Severity: Major
          Found in resources/js/wysiwyg/lexical/link/index.ts - About 3 hrs to fix

            MediaNode has 30 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class MediaNode extends ElementNode {
                __id: string = '';
                __alignment: CommonBlockAlignment = '';
                __tag: MediaNodeTag;
                __attributes: Record<string, string> = {};
            Severity: Minor
            Found in resources/js/wysiwyg/nodes/media.ts - About 3 hrs to fix

              ListItemNode has 30 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export class ListItemNode extends ElementNode {
                /** @internal */
                __value: number;
                /** @internal */
                __checked?: boolean;
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/list/LexicalListItemNode.ts - About 3 hrs to fix

                File LexicalLinkNode.test.ts has 317 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.

                  Function $createNodesFromDOM has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function $createNodesFromDOM(
                    node: Node,
                    editor: LexicalEditor,
                    allArtificialNodes: Array<ArtificialNode__DO_NOT_USE>,
                    hasBlockAncestorLexicalNode: boolean,
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/html/index.ts - About 3 hrs to fix

                    Function deleteCharacter has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      deleteCharacter(isBackward: boolean): void {
                        const wasCollapsed = this.isCollapsed();
                        if (this.isCollapsed()) {
                          const anchor = this.anchor;
                          let anchorNode: TextNode | ElementNode | null = anchor.getNode();
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

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

                      export function $createTableNodeWithDimensions(
                        rowCount: number,
                        columnCount: number,
                        includeHeaders: InsertTableCommandPayloadHeaders = true,
                      ): TableNode {
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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 $updateElementSelectionOnCreateDeleteNode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function $updateElementSelectionOnCreateDeleteNode(
                        selection: RangeSelection,
                        parentNode: LexicalNode,
                        nodeOffset: number,
                        times = 1,
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.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

                      Severity
                      Category
                      Status
                      Source
                      Language