BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

Function register has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function register(editor) {
    // Tasklist UI buttons
    editor.ui.registry.addIcon('tasklist', '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22,8c0-0.55-0.45-1-1-1h-7c-0.55,0-1,0.45-1,1s0.45,1,1,1h7C21.55,9,22,8.55,22,8z M13,16c0,0.55,0.45,1,1,1h7 c0.55,0,1-0.45,1-1c0-0.55-0.45-1-1-1h-7C13.45,15,13,15.45,13,16z M10.47,4.63c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25 c-0.39,0.39-1.02,0.39-1.42,0L2.7,8.16c-0.39-0.39-0.39-1.02,0-1.41c0.39-0.39,1.02-0.39,1.41,0l1.42,1.42l3.54-3.54 C9.45,4.25,10.09,4.25,10.47,4.63z M10.48,12.64c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25c-0.39,0.39-1.02,0.39-1.42,0L2.7,16.16 c-0.39-0.39-0.39-1.02,0-1.41s1.02-0.39,1.41,0l1.42,1.42l3.54-3.54C9.45,12.25,10.09,12.25,10.48,12.64L10.48,12.64z"/></svg>');
    editor.ui.registry.addToggleButton('tasklist', {
        tooltip: 'Task list',
Severity: Major
Found in resources/js/wysiwyg-tinymce/plugins-tasklist.js - About 2 hrs to fix

    Function $updateTextNodeFromDOMContent has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function $updateTextNodeFromDOMContent(
      textNode: TextNode,
      textContent: string,
      anchorOffset: null | number,
      focusOffset: null | number,
    Severity: Major
    Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 2 hrs to fix

      Function updateDOM has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        updateDOM(
          prevNode: LinkNode,
          anchor: LinkHTMLElementType,
          config: EditorConfig,
        ): boolean {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/link/index.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 moveNativeSelectionForward has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      function moveNativeSelectionForward() {
        const domSelection = window.getSelection()!;
        const anchorNode = domSelection.anchorNode!;
        const anchorOffset = domSelection.anchorOffset!;
      
      
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.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 $insertNodeToNearestRoot has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $insertNodeToNearestRoot<T extends LexicalNode>(node: T): T {
        const selection = $getSelection() || $getPreviousSelection();
      
        if ($isRangeSelection(selection)) {
          const {focus} = selection;
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/utils/index.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 $toggleLink has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $toggleLink(
        url: null | string,
        attributes: LinkAttributes = {},
      ): void {
        const {target, title} = attributes;
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/link/index.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 $deleteTableRow__EXPERIMENTAL has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $deleteTableRow__EXPERIMENTAL(): 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 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 addRootElementEvents has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      export function addRootElementEvents(
        rootElement: HTMLElement,
        editor: LexicalEditor,
      ): void {
        // We only want to have a single global selectionchange event handler, shared
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalEvents.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 insertNodes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        insertNodes(nodes: Array<LexicalNode>): void {
          if (nodes.length === 0) {
            return;
          }
          if (this.anchor.key === 'root') {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.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 getNodesForPageEditor has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
          return [
              CalloutNode,
              CustomHeadingNode,
              CustomQuoteNode,
      Severity: Major
      Found in resources/js/wysiwyg/nodes/index.ts - About 2 hrs to fix

        File LexicalListNode.ts has 286 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * Copyright (c) Meta Platforms, Inc. and affiliates.
         *
         * This source code is licensed under the MIT license found in the
         * LICENSE file in the root directory of this source tree.
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/list/LexicalListNode.ts - About 2 hrs to fix

          Function $convertTextDOMNode has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function $convertTextDOMNode(domNode: Node): DOMConversionOutput {
            const domNode_ = domNode as Text;
            const parentDom = domNode.parentElement;
            invariant(
              parentDom !== null,
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 2 hrs to fix

            LinkNode has 25 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class LinkNode extends ElementNode {
              /** @internal */
              __url: string;
              /** @internal */
              __target: null | string;
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/link/index.ts - About 2 hrs to fix

              Function register has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function register(editor) {
                  editor.ui.registry.addIcon('details', '<svg width="24" height="24"><path d="M8.2 9a.5.5 0 0 0-.4.8l4 5.6a.5.5 0 0 0 .8 0l4-5.6a.5.5 0 0 0-.4-.8ZM20.122 18.151h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7zM20.122 3.042h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7z"/></svg>');
                  editor.ui.registry.addIcon('togglefold', '<svg height="24"  width="24"><path d="M8.12 19.3c.39.39 1.02.39 1.41 0L12 16.83l2.47 2.47c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.02-.39-1.41 0l-3.17 3.17c-.4.38-.4 1.02-.01 1.41zm7.76-14.6c-.39-.39-1.02-.39-1.41 0L12 7.17 9.53 4.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.03 0 1.42l3.17 3.17c.39.39 1.02.39 1.41 0l3.17-3.17c.4-.39.4-1.03.01-1.42z"/></svg>');
                  editor.ui.registry.addIcon('togglelabel', '<svg height="18" width="18" viewBox="0 0 24 24"><path d="M21.41,11.41l-8.83-8.83C12.21,2.21,11.7,2,11.17,2H4C2.9,2,2,2.9,2,4v7.17c0,0.53,0.21,1.04,0.59,1.41l8.83,8.83 c0.78,0.78,2.05,0.78,2.83,0l7.17-7.17C22.2,13.46,22.2,12.2,21.41,11.41z M6.5,8C5.67,8,5,7.33,5,6.5S5.67,5,6.5,5S8,5.67,8,6.5 S7.33,8,6.5,8z"/></svg>');
              
              
              Severity: Major
              Found in resources/js/wysiwyg-tinymce/plugins-details.js - About 2 hrs to fix

                File LdapService.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace BookStack\Access;
                
                use BookStack\Exceptions\JsonDebugException;
                Severity: Minor
                Found in app/Access/LdapService.php - About 2 hrs to fix

                  Function insertList has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function insertList(editor: LexicalEditor, listType: ListType): void {
                    editor.update(() => {
                      const selection = $getSelection();
                  
                      if (selection !== null) {
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 2 hrs to fix

                    Function $deleteTableRow__EXPERIMENTAL has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function $deleteTableRow__EXPERIMENTAL(): 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 2 hrs to fix

                      Function onInput has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function onInput(event: InputEvent, editor: LexicalEditor): void {
                        // We don't want the onInput to bubble, in the case of nested editors.
                        event.stopPropagation();
                        updateEditor(editor, () => {
                          const selection = $getSelection();
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 2 hrs to fix

                        Function syncPropertiesFromYjs has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function syncPropertiesFromYjs(
                          binding: Binding,
                          sharedType: XmlText | YMap<unknown> | XmlElement,
                          lexicalNode: LexicalNode,
                          keysChanged: null | Set<string>,
                        Severity: Minor
                        Found in resources/js/wysiwyg/lexical/yjs/Utils.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 $computeTableMapSkipCellCheck has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function $computeTableMapSkipCellCheck(
                          grid: TableNode,
                          cellA: null | TableCellNode,
                          cellB: null | TableCellNode,
                        ): [TableMapType, TableMapValueType | null, TableMapValueType | null] {
                        Severity: Minor
                        Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.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

                        Severity
                        Category
                        Status
                        Source
                        Language