BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

Function syncCursorPositions has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

export function syncCursorPositions(
  binding: Binding,
  provider: Provider,
): void {
  const awarenessStates = Array.from(provider.awareness.getStates());
Severity: Minor
Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 4 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 onSelectionChange has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function onSelectionChange(
  domSelection: Selection,
  editor: LexicalEditor,
  isActive: boolean,
): void {
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 4 hrs to fix

    Function modify has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Selection.prototype.modify = function (alter, direction, granularity) {
        // This is not a thorough implementation, it was more to get tests working
        // given the refactor to use this selection method.
        const symbol = Object.getOwnPropertySymbols(this)[0];
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
    Severity: Major
    Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 4 hrs to fix

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

      export function $convertTableCellNodeElement(
          domNode: Node,
      ): DOMConversionOutput {
          const domNode_ = domNode as HTMLTableCellElement;
          const nodeName = domNode.nodeName.toLowerCase();
      Severity: Minor
      Found in resources/js/wysiwyg/nodes/custom-table-cell.ts - About 4 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 $convertTableCellNodeElement has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $convertTableCellNodeElement(
        domNode: Node,
      ): DOMConversionOutput {
        const domNode_ = domNode as HTMLTableCellElement;
        const nodeName = domNode.nodeName.toLowerCase();
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableCellNode.ts - About 4 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 modify has 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        modify(
          alter: 'move' | 'extend',
          isBackward: boolean,
          granularity: 'character' | 'word' | 'lineboundary',
        ): void {
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 hrs to fix

        Function splice has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          splice(
            start: number,
            deleteCount: number,
            nodesToInsert: Array<LexicalNode>,
          ): this {
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/nodes/LexicalElementNode.ts - About 4 hrs to fix

          Function registerNestedElementResolver has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          export function registerNestedElementResolver<N extends ElementNode>(
            editor: LexicalEditor,
            targetNode: Klass<N>,
            cloneNode: (from: N) => N,
            handleOverlap: (from: N, to: N) => void,
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/utils/index.ts - About 4 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 $unmergeCell has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          export function $unmergeCell(): 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 4 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 $createNode has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          function $createNode(
            key: NodeKey,
            parentDOM: null | HTMLElement,
            insertDOM: null | Node,
          ): HTMLElement {
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 4 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 $patchStyleText has 106 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function $patchStyleText(
            selection: BaseSelection,
            patch: Record<
              string,
              | string
          Severity: Major
          Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix

            Function getMainEditorFullToolbar has 105 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function getMainEditorFullToolbar(context: EditorUiContext): EditorContainerUiElement {
            
                const inRtlMode = context.manager.getDefaultDirection() === 'rtl';
            
                return new EditorSimpleClassContainer('editor-toolbar-main', [
            Severity: Major
            Found in resources/js/wysiwyg/ui/toolbars.ts - About 4 hrs to fix

              Function positionNodeOnRange has 105 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function positionNodeOnRange(
                editor: LexicalEditor,
                range: Range,
                onReposition: (node: Array<HTMLElement>) => void,
              ): () => void {
              Severity: Major
              Found in resources/js/wysiwyg/lexical/utils/positionNodeOnRange.ts - About 4 hrs to fix

                LexicalEditor has 33 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class LexicalEditor {
                  ['constructor']!: KlassConstructor<typeof LexicalEditor>;
                
                  /** The version with build identifiers for this editor (since 0.17.1) */
                  static version: string | undefined;
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 4 hrs to fix

                  Function splitText has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    splitText(...splitOffsets: Array<number>): Array<TextNode> {
                      errorOnReadOnly();
                      const self = this.getLatest();
                      const textContent = self.getTextContent();
                      const key = self.__key;
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 4 hrs to fix

                    Function extract has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                      extract(): Array<LexicalNode> {
                        const selectedNodes = this.getNodes();
                        const selectedNodesLength = selectedNodes.length;
                        const lastIndex = selectedNodesLength - 1;
                        const anchor = this.anchor;
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 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 onKeyDown has 102 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function onKeyDown(event: KeyboardEvent, editor: LexicalEditor): void {
                      lastKeyDownTimeStamp = event.timeStamp;
                      lastKeyCode = event.key;
                      if (editor.isComposing()) {
                        return;
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 4 hrs to fix

                      File lexical-node.ts has 336 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/selection/lexical-node.ts - About 4 hrs to fix

                        Function $trimTextContentFromAnchor has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function $trimTextContentFromAnchor(
                          editor: LexicalEditor,
                          anchor: Point,
                          delCount: number,
                        ): void {
                        Severity: Major
                        Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix

                          Consider simplifying this complex logical expression.
                          Open

                                if (
                                  node.isToken() ||
                                  (compositionKey !== null &&
                                    nodeKey === compositionKey &&
                                    !isComposing) ||
                          Severity: Critical
                          Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 4 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language