BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

    protected static function decodeEscapes(string $input): string
    {
        $decoded = "";
        $escaping = false;

Severity: Minor
Found in app/Search/SearchOptions.php - 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

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

    public function getAdditionalOptionsString(): string
    {
        $options = [];

        // Handle filters without UI support
Severity: Minor
Found in app/Search/SearchOptions.php - 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 ($isTextNode(anchorNode)) {
                anchorNode.select();
              }
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

              for (let i = 0; i < elements.length; i++) {
                const element = elements[i];
                target.append(element);
                lastElement = element;
              }
    Severity: Major
    Found in resources/js/wysiwyg/lexical/selection/range-selection.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (node instanceof CollabTextNode) {
                  node._text = spliceString(node._text, offset, 0, insertDelta);
                } else {
                  // TODO: maybe we can improve this by keeping around a redundant
                  // text node map, rather than removing all the text nodes, so there
      Severity: Major
      Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (prevSibling.nodeName === 'P') {
                    prevSibling = prevSibling.firstChild;
                  }
        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 (nextTextNode === null) {
                      throw new Error('moveNativeSelectionForward: TODO');
                    } else {
                      setNativeSelection(nextTextNode, 0, nextTextNode, 0);
                    }
          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 (
                          offset === 0 &&
                          delCount === 1 &&
                          nodeIndex > 0 &&
                          prevCollabNode instanceof CollabTextNode &&
            Severity: Major
            Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if (!_$isTextNode) {
                        anchor.node = anchorNode.childNodes[anchorOffset - 1];
                        anchor.offset = anchor.node.nodeValue.length - 1;
                      } else {
                        anchor.offset--;
              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 (lastTextNode === null) {
                            throw new Error('moveNativeSelectionBackward: TODO');
                          } else {
                            const textLength = lastTextNode.nodeValue!.length;
                            setNativeSelection(
                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 (anchorCollabNode !== null && focusCollabNode !== null) {
                              const anchorKey = anchorCollabNode.getKey();
                              const focusKey = focusCollabNode.getKey();
                              selection = cursor.selection;
                  
                  
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 45 mins to fix

                    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 (prevSibling === null) {
                                  prevSibling = anchorNode.parentElement.previousSibling.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 (nextSibling.nodeName === 'BR') {
                                    anchor.node = nextSibling;
                                    anchor.offset = 0;
                                  } else {
                                    anchor.node = nextSibling.firstChild;
                        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 (prevSibling.nodeName === 'BR') {
                                      anchor.node = prevSibling;
                                      anchor.offset = 0;
                                    } else {
                                      anchor.node = prevSibling.firstChild;
                          Severity: Major
                          Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 45 mins to fix

                            Function createBinding has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              editor: LexicalEditor,
                              provider: Provider,
                              id: string,
                              doc: Doc | null | undefined,
                              docMap: Map<string, Doc>,
                            Severity: Minor
                            Found in resources/js/wysiwyg/lexical/yjs/Bindings.ts - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                      if (anchorNode.nodeName === 'BR') {
                                        const parentNode = anchorNode.parentNode!;
                                        const childNodes = Array.from(parentNode.childNodes);
                                        anchorOffset = childNodes.indexOf(anchorNode as ChildNode);
                                        anchorNode = parentNode;
                              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 (nextSibling === null) {
                                            nextSibling = anchorNode.parentElement.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

                                          for (let i = 0; i < segmentsLength; i++) {
                                            const segment = segments[i];
                                            const nextIndex = segment.index + segment.segment.length;
                                  
                                            if (segment.isWordLike) {
                                  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

                                              for (let i = 0; i < elements.length; i++) {
                                                const element = elements[i];
                                                firstChild.insertBefore(element);
                                                lastElement = element;
                                              }
                                    Severity: Major
                                    Found in resources/js/wysiwyg/lexical/selection/range-selection.ts - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language