BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

    test('LinkNode.getRel()', async () => {
      const {editor} = testEnv;

      await editor.update(() => {
        const linkNode = new LinkNode('https://example.com/foo', {
resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 140..151

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

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

Method index has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function index(
        Request $request,
        ActivityQueries $activities,
        QueryRecentlyViewed $recentlyViewed,
        QueryTopFavourites $topFavourites,
Severity: Major
Found in app/App/HomeController.php - About 2 hrs to fix

    Function syncCursorPositions has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function syncCursorPositions(
      binding: Binding,
      provider: Provider,
    ): void {
      const awarenessStates = Array.from(provider.awareness.getStates());
    Severity: Major
    Found in resources/js/wysiwyg/lexical/yjs/SyncCursors.ts - About 2 hrs to fix

      EditorUIManager has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class EditorUIManager {
      
          protected modalDefinitionsByKey: Record<string, EditorFormModalDefinition> = {};
          protected activeModalsByKey: Record<string, EditorFormModal> = {};
          protected decoratorConstructorsByType: Record<string, typeof EditorDecorator> = {};
      Severity: Minor
      Found in resources/js/wysiwyg/ui/framework/manager.ts - About 2 hrs to fix

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

            try {
                const img = await DrawIO.upload(pngData, options.pageId);
                pageEditor.undoManager.transact(() => {
                    pageEditor.dom.setAttrib(id, 'src', img.url);
                    pageEditor.dom.setAttrib(wrapId, 'drawio-diagram', img.id);
        Severity: Major
        Found in resources/js/wysiwyg-tinymce/plugin-drawio.js and 1 other location - About 2 hrs to fix
        resources/js/wysiwyg-tinymce/plugin-drawio.js on lines 52..61

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

        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

                try {
                    const img = await DrawIO.upload(pngData, options.pageId);
                    pageEditor.undoManager.transact(() => {
                        pageEditor.dom.setAttrib(imgElem, 'src', img.url);
                        pageEditor.dom.setAttrib(currentNode, 'drawio-diagram', img.id);
        Severity: Major
        Found in resources/js/wysiwyg-tinymce/plugin-drawio.js and 1 other location - About 2 hrs to fix
        resources/js/wysiwyg-tinymce/plugin-drawio.js on lines 72..82

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

        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 $deleteTableColumn__EXPERIMENTAL has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function $deleteTableColumn__EXPERIMENTAL(): void {
          const selection = $getSelection();
          invariant(
            $isRangeSelection(selection) || $isTableSelection(selection),
            'Expected a RangeSelection or TableSelection',
        Severity: Major
        Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 2 hrs to fix

          Function createMergeActionGetter has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createMergeActionGetter(
            editor: LexicalEditor,
            delay: number,
          ): (
            prevEditorState: null | EditorState,
          Severity: Major
          Found in resources/js/wysiwyg/lexical/history/index.ts - About 2 hrs to fix

            Function $applyAllTransforms has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function $applyAllTransforms(
              editorState: EditorState,
              editor: LexicalEditor,
            ): void {
              const dirtyLeaves = editor._dirtyLeaves;
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 2 hrs to fix

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

                        case 'paste_plain': {
                          rootElement.dispatchEvent(
                            Object.assign(
                              new Event('paste', {
                                bubbles: true,
              resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts on lines 827..848
              resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts on lines 850..871

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

              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

                        case 'paste_html': {
                          rootElement.dispatchEvent(
                            Object.assign(
                              new Event('paste', {
                                bubbles: true,
              resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts on lines 804..825
              resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts on lines 827..848

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

              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

                        case 'paste_lexical': {
                          rootElement.dispatchEvent(
                            Object.assign(
                              new Event('paste', {
                                bubbles: true,
              resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts on lines 804..825
              resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts on lines 850..871

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

              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 (parentNode.is(lastPointNode)) {
                    const lastPointOffset = lastPoint.offset;
                    if (
                      (nodeOffset <= lastPointOffset && times > 0) ||
                      (nodeOffset < lastPointOffset && times < 0)
              Severity: Major
              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 2 hrs to fix
              resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2375..2387

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

              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 (parentNode.is(firstPointNode)) {
                    const firstPointOffset = firstPoint.offset;
                    if (
                      (nodeOffset <= firstPointOffset && times > 0) ||
                      (nodeOffset < firstPointOffset && times < 0)
              Severity: Major
              Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 2 hrs to fix
              resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2388..2400

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

              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 defineCodeBlockCustomElement has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              function defineCodeBlockCustomElement(editor) {
                  const doc = editor.getDoc();
                  const win = doc.defaultView;
              
                  class CodeBlockElement extends win.HTMLElement {
              Severity: Minor
              Found in resources/js/wysiwyg-tinymce/plugin-codeeditor.js - 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 getChangeType has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              function getChangeType(
                prevEditorState: null | EditorState,
                nextEditorState: EditorState,
                dirtyLeavesSet: Set<NodeKey>,
                dirtyElementsSet: Map<NodeKey, IntentionallyMarkedAsDirtyElement>,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/history/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 reconcileElementTerminatingLineBreak has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              function reconcileElementTerminatingLineBreak(
                prevElement: null | ElementNode,
                nextElement: ElementNode,
                dom: HTMLElement,
              ): void {
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.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 setRootElement has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                setRootElement(nextRootElement: null | HTMLElement): void {
                  const prevRootElement = this._rootElement;
              
                  if (nextRootElement !== prevRootElement) {
                    const classNames = getCachedClassNameArray(this._config.theme, 'root');
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/LexicalEditor.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 select has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                select(_anchorOffset?: number, _focusOffset?: number): RangeSelection {
                  errorOnReadOnly();
                  const selection = $getSelection();
                  let anchorOffset = _anchorOffset;
                  let focusOffset = _focusOffset;
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/nodes/LexicalElementNode.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 buildForEditor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function buildForEditor(options) {
                  // Set language
                  window.tinymce.addI18n(options.language, options.translationMap);
              
                  // BookStack Version
              Severity: Major
              Found in resources/js/wysiwyg-tinymce/config.js - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language