BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

        await editor.update(() => {
          const selection = $getSelection();
          invariant(
            $isRangeSelection(selection),
            'isRangeSelection(selection)',
resources/js/wysiwyg/lexical/core/__tests__/unit/HTMLCopyAndPaste.test.ts on lines 102..109
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalTabNode.test.ts on lines 66..70
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalTabNode.test.ts on lines 104..108

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

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

      await editor.update(() => {
        const selection = $getSelection();
        invariant($isRangeSelection(selection), 'isRangeSelection(selection)');
        $insertDataTransferForRichText(dataTransfer, selection, editor);
      });
resources/js/wysiwyg/lexical/core/__tests__/unit/HTMLCopyAndPaste.test.ts on lines 102..109
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalTabNode.test.ts on lines 104..108
resources/js/wysiwyg/lexical/table/__tests__/unit/LexicalTableNode.test.ts on lines 130..137

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

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 isMoveDown(
  key: string,
  ctrlKey: boolean,
  metaKey: boolean,
): boolean {
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 1 other location - About 40 mins to fix
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 1007..1013

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

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

      [
        'change in text',
        {
          format: IS_BOLD,
          mode: 'normal',
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalTextNode.test.ts on lines 716..732

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

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 updateForPage(Request $request, string $bookSlug, string $pageSlug)
    {
        $page = $this->queries->pages->findVisibleBySlugsOrFail($bookSlug, $pageSlug);
        $this->checkOwnablePermission('restrictions-manage', $page);

Severity: Minor
Found in app/Permissions/PermissionsController.php and 1 other location - About 40 mins to fix
app/Permissions/PermissionsController.php on lines 68..78

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

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 updateForChapter(Request $request, string $bookSlug, string $chapterSlug)
    {
        $chapter = $this->queries->chapters->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
        $this->checkOwnablePermission('restrictions-manage', $chapter);

Severity: Minor
Found in app/Permissions/PermissionsController.php and 1 other location - About 40 mins to fix
app/Permissions/PermissionsController.php on lines 38..48

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

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 (
        nodeName === 'h1' ||
        nodeName === 'h2' ||
        nodeName === 'h3' ||
        nodeName === 'h4' ||
Severity: Major
Found in resources/js/wysiwyg/nodes/custom-heading.ts - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

                if (
                  offset === 0 &&
                  delCount === 1 &&
                  nodeIndex > 0 &&
                  prevCollabNode instanceof CollabTextNode &&
    Severity: Major
    Found in resources/js/wysiwyg/lexical/yjs/CollabElementNode.ts - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                (_$isTextNode && anchorOffset === anchorNode.textContent.length) ||
                (!_$isTextNode &&
                  (anchorNode.childNodes.length === anchorOffset ||
                    (anchorNode.childNodes.length === 1 &&
      Severity: Major
      Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            if (
              // We might have removed a node that no longer exists
              !anchorNode.isAttached() ||
              !focusNode.isAttached() ||
              // If we've split a node, then the offset might not be right
        Severity: Major
        Found in resources/js/wysiwyg/lexical/yjs/Utils.ts - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              } else if ($isRangeSelection(selection)) {
                const tableCellNode = $findMatchingParent(
                  selection.anchor.getNode(),
                  (n) => $isTableCellNode(n),
                );
          Severity: Major
          Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if (
                  nextAnchorNode &&
                  prevAnchorNode &&
                  !prevEditorState._nodeMap.has(nextAnchorNode.__key) &&
                  $isTextNode(nextAnchorNode) &&
            Severity: Major
            Found in resources/js/wysiwyg/lexical/history/index.ts - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (
                        selection &&
                        !selection.is(prevSelection) &&
                        ($isTableSelection(selection) || $isTableSelection(prevSelection)) &&
                        tableObserver.tableSelection &&
              Severity: Major
              Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                  if (
                    isCollapsed &&
                    (prevSelection === null ||
                      anchorFormatOrStyleChanged ||
                      ($isRangeSelection(prevSelection) &&
                Severity: Major
                Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                        if (
                          // If it has been 30ms since the last keydown, then we should
                          // apply the empty space heuristic. We can't do this for Safari,
                          // as the keydown fires after composition start.
                          event.timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY ||
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                      if (
                        !tags.has('skip-scroll-into-view') &&
                        nextSelection.isCollapsed() &&
                        rootElement !== null &&
                        rootElement === document.activeElement
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if (
                                isPossiblyAndroidKeyPress(event.timeStamp) &&
                                editor.isComposing() &&
                                isSelectionAnchorSameAsFocus
                              ) {
                      Severity: Major
                      Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                          if (
                            anchorOffset === nextAnchorOffset &&
                            focusOffset === nextFocusOffset &&
                            anchorDOMNode === nextAnchorNode &&
                            focusDOMNode === nextFocusNode && // Badly interpreted range selection when collapsed - #1482
                        Severity: Major
                        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                              } else if (
                                (isCollapsed || isBackward) &&
                                nextSibling === null &&
                                $isElementNode(parent) &&
                                parent.isInline() &&
                          Severity: Major
                          Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                              if (
                                nodeName === 'h1' ||
                                nodeName === 'h2' ||
                                nodeName === 'h3' ||
                                nodeName === 'h4' ||
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/rich-text/index.ts - About 40 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language