BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Function $reconcileNodeChildren has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  nextElement: ElementNode,
  prevChildren: Array<NodeKey>,
  nextChildren: Array<NodeKey>,
  prevChildrenLength: number,
  nextChildrenLength: number,
Severity: Minor
Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

          if (isCopy(key, shiftKey, metaKey, ctrlKey)) {
            event.preventDefault();
            dispatchCommand(editor, COPY_COMMAND, event);
          } else if (isCut(key, shiftKey, metaKey, ctrlKey)) {
            event.preventDefault();
    Severity: Major
    Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                } else if (node === lastNode) {
                  text = isBefore
                    ? text.slice(0, focusOffset)
                    : text.slice(0, anchorOffset);
                }
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (
                    anchorNode.is(focusNode) ||
                    (isBackward && offset !== 0) ||
                    (!isBackward && offset !== textContentSize)
                  ) {
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (removedDOMsLength !== unremovedBRs) {
                        if (targetDOM === rootElement) {
                          targetNode = internalGetRoot(currentEditorState);
                        }
          
          
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalMutations.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if (
                        // eslint-disable-next-line no-prototype-builtins
                        !proto.hasOwnProperty('exportJSON')
                      ) {
                        console.warn(
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 45 mins to fix

              Function $garbageCollectDetachedDeepChildNodes has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                node: ElementNode,
                parentKey: NodeKey,
                prevNodeMap: NodeMap,
                nodeMap: NodeMap,
                nodeMapDelete: Array<NodeKey>,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/LexicalGC.ts - About 45 mins to fix

                Function drawReceive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function drawReceive(event: MessageEvent) {
                    if (!event.data || event.data.length < 1) return;
                    if (event.origin !== lastApprovedOrigin) return;
                
                    const message = JSON.parse(event.data);
                Severity: Minor
                Found in resources/js/services/drawio.ts - About 45 mins 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

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

                    editor.ui.registry.addButton('customhr', {
                        icon: 'horizontal-rule',
                        tooltip: 'Insert horizontal line',
                        onAction() {
                            editor.execCommand('InsertHorizontalRule');
                Severity: Major
                Found in resources/js/wysiwyg-tinymce/plugins-customhr.js and 3 other locations - About 45 mins to fix
                resources/js/wysiwyg-tinymce/plugin-codeeditor.js on lines 161..167
                resources/js/wysiwyg-tinymce/plugin-codeeditor.js on lines 169..175
                resources/js/wysiwyg-tinymce/plugins-details.js on lines 180..186

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

                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

                Avoid deeply nested control flow statements.
                Open

                            if (!klass.hasOwnProperty(method)) {
                              console.warn(`${name} must implement static "${method}" method`);
                            }
                Severity: Major
                Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (proto instanceof DecoratorNode) {
                              // eslint-disable-next-line no-prototype-builtins
                              if (!proto.hasOwnProperty('decorate')) {
                                console.warn(
                                  `${proto.constructor.name} must implement "decorate" method`,
                  Severity: Major
                  Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              for (let j = 0; j < listenersLength; j++) {
                                if (listeners[j](payload, editor) === true) {
                                  return true;
                                }
                              }
                    Severity: Major
                    Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 45 mins to fix

                      Function createTextInnerDOM has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        innerDOM: HTMLElement,
                        node: TextNode,
                        innerTag: string,
                        format: number,
                        text: string,
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (node.isAttached()) {
                                        node.remove();
                                      }
                        Severity: Major
                        Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    if (prevFormat & flag) {
                                      domClassList.remove(...classNames);
                                    }
                          Severity: Major
                          Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 45 mins to fix

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

                                editor.ui.registry.addButton('codeeditor', {
                                    tooltip: 'Insert code block',
                                    icon: 'codeblock',
                                    onAction() {
                                        editor.execCommand('codeeditor');
                            Severity: Major
                            Found in resources/js/wysiwyg-tinymce/plugin-codeeditor.js and 3 other locations - About 45 mins to fix
                            resources/js/wysiwyg-tinymce/plugin-codeeditor.js on lines 169..175
                            resources/js/wysiwyg-tinymce/plugins-customhr.js on lines 12..18
                            resources/js/wysiwyg-tinymce/plugins-details.js on lines 180..186

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

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

                            function parseRefs(name: string, element: HTMLElement):
                                {refs: Record<string, HTMLElement>, manyRefs: Record<string, HTMLElement[]>} {
                                const refs: Record<string, HTMLElement> = {};
                                const manyRefs: Record<string, HTMLElement[]> = {};
                            
                            
                            Severity: Minor
                            Found in resources/js/services/components.ts - About 45 mins 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

                            Avoid deeply nested control flow statements.
                            Open

                                      if (siblingDOM != null) {
                                        dom.insertBefore(childDOM, siblingDOM);
                                      } else {
                                        dom.appendChild(childDOM);
                                      }
                            Severity: Major
                            Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 45 mins to fix

                              Function mergeWithSibling has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                mergeWithSibling(target: TextNode): TextNode {
                                  const isBefore = target === this.getPreviousSibling();
                                  if (!isBefore && target !== this.getNextSibling()) {
                                    invariant(
                                      false,
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 45 mins 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

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

                                  editor.ui.registry.addButton('editcodeeditor', {
                                      tooltip: 'Edit code block',
                                      icon: 'edit-block',
                                      onAction() {
                                          editor.execCommand('codeeditor');
                              Severity: Major
                              Found in resources/js/wysiwyg-tinymce/plugin-codeeditor.js and 3 other locations - About 45 mins to fix
                              resources/js/wysiwyg-tinymce/plugin-codeeditor.js on lines 161..167
                              resources/js/wysiwyg-tinymce/plugins-customhr.js on lines 12..18
                              resources/js/wysiwyg-tinymce/plugins-details.js on lines 180..186

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

                              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