BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Function getNodes has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getNodes(): Array<LexicalNode> {
    const cachedNodes = this._cachedNodes;
    if (cachedNodes !== null) {
      return cachedNodes;
    }
Severity: Major
Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts - About 5 hrs to fix

    File clipboard.ts has 386 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Copyright (c) Meta Platforms, Inc. and affiliates.
     *
     * This source code is licensed under the MIT license found in the
     * LICENSE file in the root directory of this source tree.
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/clipboard/clipboard.ts - About 5 hrs to fix

      Function positionNodeOnRange has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function positionNodeOnRange(
        editor: LexicalEditor,
        range: Range,
        onReposition: (node: Array<HTMLElement>) => void,
      ): () => void {
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/utils/positionNodeOnRange.ts - About 5 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 getNodes has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        getNodes(): Array<LexicalNode> {
          const cachedNodes = this._cachedNodes;
          if (cachedNodes !== null) {
            return cachedNodes;
          }
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts - About 5 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 formatText has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        formatText(formatType: TextFormatType): void {
          if (this.isCollapsed()) {
            this.toggleFormat(formatType);
            // When changing format, we should stop composition
            $setCompositionKey(null);
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 5 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 $updateTextNodeFromDOMContent has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $updateTextNodeFromDOMContent(
        textNode: TextNode,
        textContent: string,
        anchorOffset: null | number,
        focusOffset: null | number,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 5 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 $convertTextDOMNode has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      function $convertTextDOMNode(domNode: Node): DOMConversionOutput {
        const domNode_ = domNode as Text;
        const parentDom = domNode.parentElement;
        invariant(
          parentDom !== null,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 5 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

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

          test('LinkNode.createDOM() with target, rel and title', 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 252..274

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

      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

          test('AutoLinkNode.createDOM() with target, rel and title', async () => {
            const {editor} = testEnv;
      
            await editor.update(() => {
              const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
      resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 197..219

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

      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

          test('$createListItemNode()', async () => {
            const {editor} = testEnv;
      
            await editor.update(() => {
              const listItemNode = new ListItemNode();
      resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalParagraphNode.test.ts on lines 130..141

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

      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

          test('$createParagraphNode()', async () => {
            const {editor} = testEnv;
      
            await editor.update(() => {
              const paragraphNode = new ParagraphNode();
      resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 1245..1257

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

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

      function $reconcileNode(
        key: NodeKey,
        parentDOM: HTMLElement | null,
      ): HTMLElement {
        const prevNode = activePrevNodeMap.get(key);
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 5 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

      File formatList.ts has 377 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Copyright (c) Meta Platforms, Inc. and affiliates.
       *
       * This source code is licensed under the MIT license found in the
       * LICENSE file in the root directory of this source tree.
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 5 hrs to fix

        Function createEditor has 125 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function createEditor(editorConfig?: CreateEditorArgs): LexicalEditor {
          const config = editorConfig || {};
          const activeEditor = internalGetActiveEditor();
          const theme = config.theme || {};
          const parentEditor =
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 5 hrs to fix

          Function $beginUpdate has 125 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function $beginUpdate(
            editor: LexicalEditor,
            updateFn: () => void,
            options?: EditorUpdateOptions,
          ): void {
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 5 hrs to fix

            Function updateDOMSelection has 124 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function updateDOMSelection(
              prevSelection: BaseSelection | null,
              nextSelection: BaseSelection | null,
              editor: LexicalEditor,
              domSelection: Selection,
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 hrs to fix

              Function selectTableNodeInDirection has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

              const selectTableNodeInDirection = (
                tableObserver: TableObserver,
                tableNode: TableNode,
                x: number,
                y: number,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 4 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 $beginUpdate has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

              function $beginUpdate(
                editor: LexicalEditor,
                updateFn: () => void,
                options?: EditorUpdateOptions,
              ): void {
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 4 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 setTextThemeClassNames has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

              function setTextThemeClassNames(
                tag: string,
                prevFormat: number,
                nextFormat: number,
                dom: HTMLElement,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 4 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

              File tables.ts has 370 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import {EditorBasicButtonDefinition, EditorButtonDefinition} from "../../framework/buttons";
              import tableIcon from "@icons/editor/table.svg";
              import deleteIcon from "@icons/editor/table-delete.svg";
              import deleteColumnIcon from "@icons/editor/table-delete-column.svg";
              import deleteRowIcon from "@icons/editor/table-delete-row.svg";
              Severity: Minor
              Found in resources/js/wysiwyg/ui/defaults/buttons/tables.ts - About 4 hrs to fix
                Severity
                Category
                Status
                Source
                Language