BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

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

  splitText(...splitOffsets: Array<number>): Array<TextNode> {
    errorOnReadOnly();
    const self = this.getLatest();
    const textContent = self.getTextContent();
    const key = self.__key;
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.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 updateDOMBlockCursorElement has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export function updateDOMBlockCursorElement(
  editor: LexicalEditor,
  rootElement: HTMLElement,
  nextSelection: null | BaseSelection,
): void {
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalUtils.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 findTextInLine has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

function findTextInLine(text: Text, forward: boolean): null | Text {
  let node: Node = text;
  // eslint-disable-next-line no-constant-condition
  while (true) {
    let sibling: null | Node;
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.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 register has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function register(editor) {
    editor.ui.registry.addIcon('codeblock', '<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5Z"/><path d="M11.103 15.423c.277.277.277.738 0 .922a.692.692 0 0 1-1.106 0l-4.057-3.78a.738.738 0 0 1 0-1.107l4.057-3.872c.276-.277.83-.277 1.106 0a.724.724 0 0 1 0 1.014L7.6 12.012ZM12.897 8.577c-.245-.312-.2-.675.08-.955.28-.281.727-.27 1.027.033l4.057 3.78a.738.738 0 0 1 0 1.107l-4.057 3.872c-.277.277-.83.277-1.107 0a.724.724 0 0 1 0-1.014l3.504-3.412z"/></svg>');

    editor.ui.registry.addButton('codeeditor', {
        tooltip: 'Insert code block',
Severity: Major
Found in resources/js/wysiwyg-tinymce/plugin-codeeditor.js - About 3 hrs to fix

    Function addRootElementEvents has 89 lines of code (exceeds 25 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: Major
    Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 3 hrs to fix

      Function $reconcileNode has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function $reconcileNode(
        key: NodeKey,
        parentDOM: HTMLElement | null,
      ): HTMLElement {
        const prevNode = activePrevNodeMap.get(key);
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 3 hrs to fix

        File LexicalTableSelection.ts has 313 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/table/LexicalTableSelection.ts - About 3 hrs to fix

          Entity has 29 functions (exceeds 20 allowed). Consider refactoring.
          Open

          abstract class Entity extends Model implements Sluggable, Favouritable, Viewable, Deletable, Loggable
          {
              use SoftDeletes;
              use HasCreatorAndUpdater;
              use HasOwner;
          Severity: Minor
          Found in app/Entities/Models/Entity.php - About 3 hrs to fix

            File index.ts has 311 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/html/index.ts - About 3 hrs to fix

              Function registerHistory has 86 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function registerHistory(
                editor: LexicalEditor,
                historyState: HistoryState,
                delay: number,
              ): () => void {
              Severity: Major
              Found in resources/js/wysiwyg/lexical/history/index.ts - About 3 hrs to fix

                File LexicalTableCellNode.ts has 309 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/table/LexicalTableCellNode.ts - About 3 hrs to fix

                  File media.ts has 308 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import {
                      DOMConversion,
                      DOMConversionMap, DOMConversionOutput, DOMExportOutput,
                      ElementNode,
                      LexicalEditor,
                  Severity: Minor
                  Found in resources/js/wysiwyg/nodes/media.ts - About 3 hrs to fix

                    Function defineCodeBlockCustomElement has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function defineCodeBlockCustomElement(editor) {
                        const doc = editor.getDoc();
                        const win = doc.defaultView;
                    
                        class CodeBlockElement extends win.HTMLElement {
                    Severity: Major
                    Found in resources/js/wysiwyg-tinymce/plugin-codeeditor.js - About 3 hrs to fix

                      Function updateCursor has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function updateCursor(
                        binding: Binding,
                        cursor: Cursor,
                        nextSelection: null | CursorSelection,
                        nodeMap: NodeMap,
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 3 hrs to fix

                        SearchRunner has 28 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class SearchRunner
                        {
                            /**
                             * Retain a cache of score adjusted terms for specific search options.
                             */
                        Severity: Minor
                        Found in app/Search/SearchRunner.php - About 3 hrs to fix

                          RangeSelection has 28 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          export class RangeSelection implements BaseSelection {
                            format: number;
                            style: string;
                            anchor: PointType;
                            focus: PointType;
                          Severity: Minor
                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 3 hrs to fix

                            Function $reconcileChildren has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function $reconcileChildren(
                              prevElement: ElementNode,
                              nextElement: ElementNode,
                              dom: HTMLElement,
                            ): void {
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 3 hrs to fix

                              Function removeFromParent has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function removeFromParent(node: LexicalNode): void {
                                const oldParent = node.getParent();
                                if (oldParent !== null) {
                                  const writableNode = node.getWritable();
                                  const writableParent = oldParent.getWritable();
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/yjs/Utils.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 $deleteTableColumn__EXPERIMENTAL has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function $deleteTableColumn__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 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 $insertTableRow has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function $insertTableRow(
                                tableNode: TableNode,
                                targetIndex: number,
                                shouldInsertAfter = true,
                                rowCount: number,
                              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

                              Severity
                              Category
                              Status
                              Source
                              Language