BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Consider simplifying this complex logical expression.
Open

          if (
            $isTextNode(node) &&
            textContentSize !== 0 &&
            // Exclude empty text nodes at boundaries resulting from user's selection
            !(
Severity: Critical
Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

            if (
              anchor.type === 'element' &&
              anchor.offset === 0 &&
              selection.isCollapsed() &&
              !$isRootNode(anchorNode) &&
    Severity: Critical
    Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function bookToContainedHtml(Book $book): string
          {
              $bookTree = (new BookContents($book))->getTree(false, true);
              $html = view('exports.book', [
                  'book'         => $book,
      Severity: Major
      Found in app/Entities/Tools/ExportFormatter.php and 1 other location - About 1 hr to fix
      app/Entities/Tools/ExportFormatter.php on lines 131..143

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 107.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function bookToPdf(Book $book): string
          {
              $bookTree = (new BookContents($book))->getTree(false, true);
              $html = view('exports.book', [
                  'book'         => $book,
      Severity: Major
      Found in app/Entities/Tools/ExportFormatter.php and 1 other location - About 1 hr to fix
      app/Entities/Tools/ExportFormatter.php on lines 71..83

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 107.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function updateDOM has 33 lines of code (exceeds 25 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 1 hr to fix

        Function $pasteClipboardColumns has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function $pasteClipboardColumns(editor: LexicalEditor, isBefore: boolean): void {
            const selection = $getSelection();
            const table = $getTableFromSelection(selection);
            const cells = $getTableCellsFromSelection(selection);
            const referenceCell = cells[isBefore ? 0 : cells.length - 1];
        Severity: Minor
        Found in resources/js/wysiwyg/utils/table-copy-paste.ts - About 1 hr to fix

          Method getConverterEnvironment has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getConverterEnvironment(): Environment
              {
                  $environment = new Environment([
                      'header_style'            => 'atx', // Set to 'atx' to output H1 and H2 headers as # Header1 and ## Header2
                      'suppress_errors'         => true, // Set to false to show warnings when loading malformed HTML
          Severity: Minor
          Found in app/Entities/Tools/Markdown/HtmlToMarkdown.php - About 1 hr to fix

            Function updateContextToolbars has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected updateContextToolbars(update: EditorUiStateUpdate): void {
                    for (let i = this.activeContextToolbars.length - 1; i >= 0; i--) {
                        const toolbar = this.activeContextToolbars[i];
                        toolbar.destroy();
                        this.activeContextToolbars.splice(i, 1);
            Severity: Minor
            Found in resources/js/wysiwyg/ui/framework/manager.ts - About 1 hr to fix

              Function $syncLocalCursorPosition has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function $syncLocalCursorPosition(
                binding: Binding,
                provider: Provider,
              ): void {
                const awareness = provider.awareness;
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 1 hr to fix

                Function $setBlocksType has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function $setBlocksType(
                  selection: BaseSelection | null,
                  createElement: () => ElementNode,
                ): void {
                  if (selection === null) {
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/selection/range-selection.ts - About 1 hr to fix

                  Function $createListOrMerge has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function $createListOrMerge(node: ElementNode, listType: ListType): ListNode {
                    if ($isListNode(node)) {
                      return node;
                    }
                  
                  
                  Severity: Minor
                  Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 1 hr to fix

                    Function $splitNodeAtPoint has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function $splitNodeAtPoint(
                      node: LexicalNode,
                      offset: number,
                    ): [parent: ElementNode, offset: number] {
                      const parent = node.getParent();
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                      Function processNestedUpdates has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function processNestedUpdates(
                        editor: LexicalEditor,
                        initialSkipTransforms?: boolean,
                      ): boolean {
                        const queuedUpdates = editor._updates;
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 1 hr to fix

                        Function registerCommand has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          registerCommand<P>(
                            command: LexicalCommand<P>,
                            listener: CommandListener<P>,
                            priority: CommandListenerPriority,
                          ): () => void {
                        Severity: Minor
                        Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 1 hr to fix

                          Function $splitNode has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function $splitNode(
                            node: ElementNode,
                            offset: number,
                          ): [ElementNode | null, ElementNode] {
                            let startNode = node.getChildAtIndex(offset);
                          Severity: Minor
                          Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 1 hr to fix

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                editor.registerCommand<boolean>(
                                  DELETE_CHARACTER_COMMAND,
                                  (isBackward) => {
                                    const selection = $getSelection();
                                    if (!$isRangeSelection(selection)) {
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 3 other locations - About 1 hr to fix
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 563..574
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 575..586
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 662..673

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 61.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                editor.registerCommand<boolean>(
                                  DELETE_WORD_COMMAND,
                                  (isBackward) => {
                                    const selection = $getSelection();
                                    if (!$isRangeSelection(selection)) {
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 3 other locations - About 1 hr to fix
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 551..562
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 575..586
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 662..673

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 61.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                async patch(url: string, data: null|Record<string, any> = null): Promise<FormattedResponse> {
                                    return this.dataRequest('PATCH', url, data);
                                }
                            Severity: Major
                            Found in resources/js/services/http.ts and 3 other locations - About 1 hr to fix
                            resources/js/services/http.ts on lines 169..171
                            resources/js/services/http.ts on lines 176..178
                            resources/js/services/http.ts on lines 190..192

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 61.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                editor.registerCommand<boolean>(
                                  DELETE_LINE_COMMAND,
                                  (isBackward) => {
                                    const selection = $getSelection();
                                    if (!$isRangeSelection(selection)) {
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 3 other locations - About 1 hr to fix
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 551..562
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 563..574
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 662..673

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 61.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                editor.registerCommand<boolean>(
                                  INSERT_LINE_BREAK_COMMAND,
                                  (selectStart) => {
                                    const selection = $getSelection();
                                    if (!$isRangeSelection(selection)) {
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 3 other locations - About 1 hr to fix
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 551..562
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 563..574
                            resources/js/wysiwyg/lexical/rich-text/index.ts on lines 575..586

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 61.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Severity
                            Category
                            Status
                            Source
                            Language