BookStackApp/BookStack

View on GitHub

Showing 889 of 1,485 total issues

Function moveNativeSelectionBackward has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function moveNativeSelectionBackward() {
  const domSelection = window.getSelection()!;
  let anchorNode = domSelection.anchorNode!;
  let anchorOffset = domSelection.anchorOffset!;

Severity: Major
Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 2 hrs to fix

    File web.php has 268 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    use BookStack\Access\Controllers as AccessControllers;
    use BookStack\Activity\Controllers as ActivityControllers;
    use BookStack\Api\ApiDocsController;
    Severity: Minor
    Found in routes/web.php - About 2 hrs to fix

      File LexicalListNode.test.ts has 268 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 formatTextUsingMatchPositions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function formatTextUsingMatchPositions(array $matchPositions, string $originalText, int $targetLength): string
            {
                $maxEnd = mb_strlen($originalText);
                $fetchAll = ($targetLength === 0);
                $contextLength = ($fetchAll ? 0 : 32);
        Severity: Minor
        Found in app/Search/SearchResultsFormatter.php - 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 updateDOM has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            updateDOM(prevNode: ImageNode, dom: HTMLElement) {
                if (prevNode.__src !== this.__src) {
                    dom.setAttribute('src', this.__src);
                }
        
        
        Severity: Minor
        Found in resources/js/wysiwyg/nodes/image.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 $appendNodesToJSON has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function $appendNodesToJSON(
          editor: LexicalEditor,
          selection: BaseSelection | null,
          currentNode: LexicalNode,
          targetArray: Array<BaseSerializedNode> = [],
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/clipboard/clipboard.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 getWordsFromString has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          const getWordsFromString = function (string: string): Array<Segment> {
            const segments: Segment[] = [];
            let wordString = '';
            let nonWordString = '';
            let i;
        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 $handleOutdent has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        export function $handleOutdent(listItemNode: ListItemNode): void {
          // go through each node and decide where to move it.
        
          if (isNestedListNode(listItemNode)) {
            return;
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/list/formatList.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 $wrapInlineNodes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function $wrapInlineNodes(nodes: LexicalNode[]) {
          // We temporarily insert the topLevelNodes into an arbitrary ElementNode,
          // since insertAfter does not work on nodes that have no parent (TO-DO: fix that).
          const virtualRoot = $createParagraphNode();
        
        
        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 setupListeners has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            setupListeners() {
                // Filter tab click
                onSelect(this.filterTabs, e => {
                    this.resetAll();
                    this.filter = e.target.dataset.filter;
        Severity: Major
        Found in resources/js/components/image-manager.js - About 2 hrs to fix

          Function $convertTableCellNodeElement has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function $convertTableCellNodeElement(
              domNode: Node,
          ): DOMConversionOutput {
              const domNode_ = domNode as HTMLTableCellElement;
              const nodeName = domNode.nodeName.toLowerCase();
          Severity: Major
          Found in resources/js/wysiwyg/nodes/custom-table-cell.ts - About 2 hrs to fix

            Function getTextContent has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getTextContent(): string {
                const nodes = this.getNodes();
                if (nodes.length === 0) {
                  return '';
                }
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 2 hrs to fix

              Function watchMarkerMouseDrags has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected watchMarkerMouseDrags(wrapper: HTMLElement) {
                      const _this = this;
                      let markerStart: number = 0;
                      let markerProp: 'left' | 'top' = 'left';
              
              
              Severity: Major
              Found in resources/js/wysiwyg/ui/framework/helpers/table-resizer.ts - About 2 hrs to fix

                Function $appendNodesToHTML has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function $appendNodesToHTML(
                  editor: LexicalEditor,
                  currentNode: LexicalNode,
                  parentElement: HTMLElement | DocumentFragment,
                  selection: BaseSelection | null = null,
                Severity: Major
                Found in resources/js/wysiwyg/lexical/html/index.ts - About 2 hrs to fix

                  Function build has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              build() {
                                  const generalFields: EditorFormFieldDefinition[] = [
                                      {
                                          label: 'Width', // Colgroup width
                                          name: 'width',
                  Severity: Major
                  Found in resources/js/wysiwyg/ui/defaults/forms/tables.ts - About 2 hrs to fix

                    File PageContent.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    namespace BookStack\Entities\Tools;
                    
                    use BookStack\Entities\Models\Page;
                    Severity: Minor
                    Found in app/Entities/Tools/PageContent.php - About 2 hrs to fix

                      Function isSortChangePermissible has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function isSortChangePermissible(BookSortMapItem $sortMapItem, BookChild $model, ?Entity $currentParent, ?Entity $newBook, ?Entity $newChapter): bool
                          {
                              // Stop if we can't see the current parent or new book.
                              if (!$currentParent || !$newBook) {
                                  return false;
                      Severity: Minor
                      Found in app/Entities/Tools/BookContents.php - 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 $dfs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function $dfs(
                        startingNode?: LexicalNode,
                        endingNode?: LexicalNode,
                      ): Array<DFSNode> {
                        const nodes = [];
                      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 syncPropertiesFromLexical has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function syncPropertiesFromLexical(
                        binding: Binding,
                        sharedType: XmlText | YMap<unknown> | XmlElement,
                        prevLexicalNode: null | LexicalNode,
                        nextLexicalNode: LexicalNode,
                      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 $insertTableColumn has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

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