BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

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

export function $wrapNodesImpl(
  selection: BaseSelection,
  nodes: LexicalNode[],
  nodesLength: number,
  createElement: () => ElementNode,
Severity: Minor
Found in resources/js/wysiwyg/lexical/selection/range-selection.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 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 insertText has 285 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  insertText(text: string): void {
    const anchor = this.anchor;
    const focus = this.focus;
    const format = this.format;
    const style = this.style;
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 day to fix

    modeMap has 76 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const modeMap = {
        bash: () => legacyLoad('shell'),
        c: () => legacyLoad('c'),
        css: async () => css(),
        'c++': () => legacyLoad('cpp'),
    Severity: Major
    Found in resources/js/code/languages.js - About 1 day to fix

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

      export function $trimTextContentFromAnchor(
        editor: LexicalEditor,
        anchor: Point,
        delCount: number,
      ): void {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/selection/lexical-node.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

      File LexicalEventHelpers.test.ts has 635 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.

        File index.ts has 627 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/core/__tests__/utils/index.ts - About 1 day to fix

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

          export function $patchStyleText(
            selection: BaseSelection,
            patch: Record<
              string,
              | string
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/selection/lexical-node.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 modify has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
          Open

            modify(
              alter: 'move' | 'extend',
              isBackward: boolean,
              granularity: 'character' | 'word' | 'lineboundary',
            ): void {
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.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 $internalResolveSelectionPoint has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
            Open

            function $internalResolveSelectionPoint(
              dom: Node,
              offset: number,
              lastPoint: null | PointType,
              editor: LexicalEditor,
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.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

            File LexicalElementNode.ts has 559 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/core/nodes/LexicalElementNode.ts - About 1 day to fix

              File CollabElementNode.ts has 558 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/yjs/CollabElementNode.ts - About 1 day to fix

                Function createEditor has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                Open

                export function createEditor(editorConfig?: CreateEditorArgs): LexicalEditor {
                  const config = editorConfig || {};
                  const activeEditor = internalGetActiveEditor();
                  const theme = config.theme || {};
                  const parentEditor =
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/core/LexicalEditor.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

                File LexicalElementNode.test.ts has 533 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 getTextContent has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
                  Open

                    getTextContent(): string {
                      const nodes = this.getNodes();
                      if (nodes.length === 0) {
                        return '';
                      }
                  Severity: Minor
                  Found in resources/js/wysiwyg/lexical/core/LexicalSelection.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 onBeforeInput has 206 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function onBeforeInput(event: InputEvent, editor: LexicalEditor): void {
                    const inputType = event.inputType;
                    const targetRange = getTargetRange(event);
                  
                    // We let the browser do its own thing for composition.
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 day to fix

                    Function syncChildrenFromYjs has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
                    Open

                      syncChildrenFromYjs(binding: Binding): void {
                        // Now diff the children of the collab node with that of our existing Lexical node.
                        const lexicalNode = this.getNode();
                        invariant(
                          lexicalNode !== null,
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.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 applySelectionInputs has 202 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export async function applySelectionInputs(
                      // eslint-disable-next-line @typescript-eslint/no-explicit-any
                      inputs: Record<string, any>[],
                      update: (fn: () => void) => Promise<void>,
                      editor: LexicalEditor,
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 1 day to fix

                      File index.ts has 484 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/link/index.ts - About 7 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language