BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Function $reconcileRoot has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function $reconcileRoot(
  prevEditorState: EditorState,
  nextEditorState: EditorState,
  editor: LexicalEditor,
  dirtyType: 0 | 1 | 2,
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 1 hr to fix

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

        public function edit(string $bookSlug, string $chapterSlug)
        {
            $chapter = $this->queries->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
            $this->checkOwnablePermission('chapter-update', $chapter);
    
    
    Severity: Major
    Found in app/Entities/Controllers/ChapterController.php and 1 other location - About 1 hr to fix
    app/Entities/Controllers/ChapterController.php on lines 142..150

    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 101.

    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 showDelete(string $bookSlug, string $chapterSlug)
        {
            $chapter = $this->queries->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
            $this->checkOwnablePermission('chapter-delete', $chapter);
    
    
    Severity: Major
    Found in app/Entities/Controllers/ChapterController.php and 1 other location - About 1 hr to fix
    app/Entities/Controllers/ChapterController.php on lines 105..113

    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 101.

    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

    Consider simplifying this complex logical expression.
    Open

            if ($model instanceof Chapter) {
                $hasPermission = userCan('book-update', $currentParent)
                    && userCan('book-update', $newBook)
                    && userCan('chapter-update', $model)
                    && (!$hasNewParent || userCan('chapter-create', $newBook))
    Severity: Major
    Found in app/Entities/Tools/BookContents.php - About 1 hr to fix

      Function syncLexicalUpdateToYjs has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        binding: Binding,
        provider: Provider,
        prevEditorState: EditorState,
        currEditorState: EditorState,
        dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>,
      Severity: Major
      Found in resources/js/wysiwyg/lexical/yjs/SyncEditorStates.ts - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            if (
              isLineBreakNode ||
              ($isDecoratorNode(node) && node.isInline()) ||
              ($isElementNode(node) && node.isInline()) ||
              $isTextNode(node) ||
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (
                this.isCollapsed() &&
                startOffset === firstNodeTextLength &&
                (firstNode.isSegmented() ||
                  firstNode.isToken() ||
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                } else if (
                  this.isCollapsed() &&
                  startOffset === 0 &&
                  (firstNode.isSegmented() ||
                    firstNode.isToken() ||
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if (
                    !isBackward &&
                    // Delete forward handle case
                    ((anchor.type === 'element' &&
                      $isElementNode(anchorNode) &&
              Severity: Major
              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

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

                    open() {
                        this.container.classList.add('open');
                        this.trigger.setAttribute('aria-expanded', 'true');
                        slideDown(this.content, 300);
                    }
                Severity: Major
                Found in resources/js/components/collapsible.js and 1 other location - About 1 hr to fix
                resources/js/components/collapsible.js on lines 27..31

                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 55.

                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

                    close() {
                        this.container.classList.remove('open');
                        this.trigger.setAttribute('aria-expanded', 'false');
                        slideUp(this.content, 300);
                    }
                Severity: Major
                Found in resources/js/components/collapsible.js and 1 other location - About 1 hr to fix
                resources/js/components/collapsible.js on lines 21..25

                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 55.

                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

                    updated(a, b) {
                        const aTime = Number(a.getAttribute('data-updated'));
                        const bTime = Number(b.getAttribute('data-updated'));
                        return bTime - aTime;
                    },
                Severity: Major
                Found in resources/js/components/book-sort.js and 1 other location - About 1 hr to fix
                resources/js/components/book-sort.js on lines 12..16

                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 55.

                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

                    created(a, b) {
                        const aTime = Number(a.getAttribute('data-created'));
                        const bTime = Number(b.getAttribute('data-created'));
                        return bTime - aTime;
                    },
                Severity: Major
                Found in resources/js/components/book-sort.js and 1 other location - About 1 hr to fix
                resources/js/components/book-sort.js on lines 17..21

                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 55.

                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 3 locations. Consider refactoring.
                Open

                    editor.registerCommand(
                      REMOVE_TEXT_COMMAND,
                      () => {
                        const selection = $getSelection();
                        if (!$isRangeSelection(selection)) {
                Severity: Major
                Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 2 other locations - About 1 hr to fix
                resources/js/wysiwyg/lexical/rich-text/index.ts on lines 674..685
                resources/js/wysiwyg/lexical/rich-text/index.ts on lines 911..922

                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 55.

                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 3 locations. Consider refactoring.
                Open

                    editor.registerCommand(
                      KEY_ESCAPE_COMMAND,
                      () => {
                        const selection = $getSelection();
                        if (!$isRangeSelection(selection)) {
                Severity: Major
                Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 2 other locations - About 1 hr to fix
                resources/js/wysiwyg/lexical/rich-text/index.ts on lines 616..627
                resources/js/wysiwyg/lexical/rich-text/index.ts on lines 674..685

                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 55.

                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

                    exportJSON(): SerializedCodeBlockNode {
                        return {
                            type: 'code-block',
                            version: 1,
                            id: this.__id,
                Severity: Major
                Found in resources/js/wysiwyg/nodes/code-block.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/nodes/diagram.ts on lines 136..144

                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 55.

                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

                                    if (_this.xMarkerAtStart && cellIndex > 0) {
                                        cellIndex -= 1;
                                    } else if  (_this.xMarkerAtStart && cellIndex === 0) {
                                        change = -change;
                                    }
                Severity: Major
                Found in resources/js/wysiwyg/ui/framework/helpers/table-resizer.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/ui/framework/helpers/table-resizer.ts on lines 168..172

                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 55.

                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 3 locations. Consider refactoring.
                Open

                    editor.registerCommand(
                      INSERT_PARAGRAPH_COMMAND,
                      () => {
                        const selection = $getSelection();
                        if (!$isRangeSelection(selection)) {
                Severity: Major
                Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 2 other locations - About 1 hr to fix
                resources/js/wysiwyg/lexical/rich-text/index.ts on lines 616..627
                resources/js/wysiwyg/lexical/rich-text/index.ts on lines 911..922

                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 55.

                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

                export function getActiveEditor(): LexicalEditor {
                  if (activeEditor === null) {
                    invariant(
                      false,
                      'Unable to find an active editor. ' +
                Severity: Major
                Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/lexical/core/LexicalUpdates.ts on lines 94..107

                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 55.

                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

                                        if (_this.yMarkerAtStart && rowIndex > 0) {
                                            rowIndex -= 1;
                                        } else if  (_this.yMarkerAtStart && rowIndex === 0) {
                                            change = -change;
                                        }
                Severity: Major
                Found in resources/js/wysiwyg/ui/framework/helpers/table-resizer.ts and 1 other location - About 1 hr to fix
                resources/js/wysiwyg/ui/framework/helpers/table-resizer.ts on lines 143..147

                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 55.

                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